Robert Hanson wrote:
> 
> > ...how to execute a ***multi-line*** match.
> > $_ =~ s/^(M\d+)\n^(.*)/A $1\nB $2/mi;
> > ...i am trying to match the first line, beginning
> > with M followed by consecutive digists...
> 
> You are confused about what a "multi-line" match is.  A "multi-line" match
> will attempt a match on ONE line at a time.  ...What you want is a
> "single-Line" match.  The /m modifier will never match a newline except at
> the END of the match... and the carrot is only valid at the beginning of the
> regex.


The /m option is used when you have mutiple lines in a string.  The ^
and $ anchors can be used anywhere in the pattern with the /m option. 
The /s option determines whether the dot pattern (.) will match a
newline or not.

$ perl -le'
$_ = "one two\n three four\nfive six\nseven eight";

print "1. *>$1<*>$2<*" while /^(.*)\n^(.*)$/mg;
print "2. *>$1<*>$2<*" while /^(.*)^(.*)$/smg;
print "3. *>$1<*>$2<*" while /^(.*)\n(.*)$/sg;

'
1. *>one two<*> three four<*
1. *>five six<*>seven eight<*
2. *>one two
 three four
five six
<*>seven eight<*
3. *>one two
 three four
five six<*>seven eight<*



HTH
John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to