The OP is asking why the first match is returned by $&. Even with /g the first match is returned because it is not in list context.
#!/usr/bin/perl use warnings; use strict; "AAC\nGTT"=~/^.*$/mg; print "\$& scalar context => $&\n"; my @matches = "AAC\nGTT"=~/^.*$/mg; print "\$& list context => $&\n"; print "\@matches => @matches\n"; __END__ output: $& scalar context => AAC $& list context => GTT @matches => AAC GTT
In reply to Re^2: /m pattern matching modifier
by Lotus1
in thread /m pattern matching modifier
by tandx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |