http://qs321.pair.com?node_id=526064

johnnywang has asked for the wisdom of the Perl Monks concerning the following question:

I happen to need the flip-flop after reading Flipin good, or a total flop?. The following behavior puzzles me, why does the first version print "after"? Thanks.
my @data = <DATA>; print "Using lexical varible:\n"; foreach my $line (@data){ if($line =~ /begin/../end/){ print $line; } } print "\nNot using lexical varible:\n"; foreach (@data){ if(/begin/../end/){ print; } } __DATA__ before begin 1 2 3 end after __RESULT__ Using lexical varible: begin 1 2 3 end after Not using lexical varible: begin 1 2 3 end