J
Justin C
I have:
#!/usr/bin/perl
use strict;
use warnings;
my $seen = 0;
my @arr = qw/john paul george ringo/;
for (@arr) {
($seen = 1 && next) if /^paul/;
next unless $seen;
print $_, "\n";
}
__END__
which prints no output. But if I change the `&&` to a comma it does as
expected.... ($seen = 1, next) if ...
I've just read perldoc perlop for Comma Operator, and for &&, but I
don't understand why one works and the other doesn't. Can anyone explain
this in simple terms?
Justin.
#!/usr/bin/perl
use strict;
use warnings;
my $seen = 0;
my @arr = qw/john paul george ringo/;
for (@arr) {
($seen = 1 && next) if /^paul/;
next unless $seen;
print $_, "\n";
}
__END__
which prints no output. But if I change the `&&` to a comma it does as
expected.... ($seen = 1, next) if ...
I've just read perldoc perlop for Comma Operator, and for &&, but I
don't understand why one works and the other doesn't. Can anyone explain
this in simple terms?
Justin.