in reply to unless condition not working
my $line = 'fee fi fo fum'; my $pat = qr/i smell the blood/; unless( grep /$pat/, $line ){ print "of an englishman\n"; } __END__
Prints "of an englishman", because $line doesn't match $pat
That condition is more commonly written as one of these
unless( $line =~ /$pat/ ) { ... if( not $line =~ /$pat/ ) { ... if( $line !~ /$pat/ ) { ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: unless condition not working
by perlavi (Initiate) on Dec 05, 2011 at 06:53 UTC | |
by Anonymous Monk on Dec 05, 2011 at 08:11 UTC |