in reply to Re: /m pattern matching modifier
in thread /m pattern matching modifier
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: /m pattern matching modifier
by jethro (Monsignor) on Oct 21, 2011 at 13:59 UTC |