Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: How to add an exceptio for"for loop"

by Anonymous Monk
on Mar 21, 2011 at 05:25 UTC ( [id://894413]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to add an exceptio for"for loop"
in thread How to add an exceptio for"for loop"

Do you spot anything wrong in the below line,for some reason the for loop is executed even for the element "." in @folders

foreach my $folder (grep {$_ ne "."}@folders) { }

Replies are listed 'Best First'.
Re^5: How to add an exceptio for"for loop"
by AnomalousMonk (Archbishop) on Mar 21, 2011 at 11:05 UTC

    Insofar as I understand what you're trying to do, it looks OK:

    >perl -wMstrict -le "my @folders = qw(foo .foo foo.bar foo. . .. ...); ;; foreach my $folder (grep { $_ ne '.' } @folders) { printf qq{'$folder' }; } " 'foo' '.foo' 'foo.bar' 'foo.' '..' '...'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://894413]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2024-04-18 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found