What merlyn says is true enough, although there may be some confusion depending on what version of Perl you run merlyn's example with:
[danger:jandrew:~]$ cat blah.pl #!/usr/bin/perl -w use strict; my @data = qw/one start two three stop four/; foreach (grep {not (/^start/../^stop/) =~ /^1?$|E/ } @data) { print "o> $_\n"; } [danger:jandrew:~]$ perl5.00503 blah.pl o> two o> three [danger:jandrew:~]$ perl5.6.1 blah.pl o> one o> start o> two o> three o> stop o> four
Because, in 5.6+, the not operator with parens acts like a function (returns the negation of what's in the parens), so you'd want another set of parens to properly delimit what we want to negate (or use a unary +):
my @data = qw/one start two three stop four/; foreach (grep {not ((/^start/../^stop/) =~ /^1?$|E/) } @data) { print "o> $_\n"; } # or: my @data = qw/one start two three stop four/; foreach (grep {not +(/^start/../^stop/) =~ /^1?$|E/ } @data) { print "o> $_\n"; }
In reply to Re: Re: Re: Re: flip-flop operator and sequence number
by danger
in thread flip-flop operator and sequence number
by iakobski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |