Ng, Bill asked on April 18, 2006 12:59 PM
> So if my array was:
> @a=(1,2,3,4,5);
> And we assume that I don't want to execute the block if the
> value of $_ is 3 ...
>
> Then, in my head, I'm looking for the WORKING (key word there)
> version of this:
> -----------
> @a = (1,2,3,4,5);
> if ($_ != 3) for (@a)
> {
> print "something";
> &doSomething();
> print "somethingelse";
> &yada($yada{$ya})
> }
> -------------
use strict;
use warnings;
my @a=(1..5);
# don't like this
#
print grep {$_ != 3} (1 .. 5);
# don't like this either
#
for (grep {$_ != 3} @a)
{
print "$_ ";
}
# OK
#
for (@a)
{
($_ == 3) and next; # or: next if $_ == 3;
print "$_ ";
}
#--Suresh
__END__
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs