thanks Rob,
it worked like a charm.

--- "Hanson, Robert" <[EMAIL PROTECTED]> 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.
> 
> Something like this *might* be what you are looking
> for if I understand
> correctly...
> 
> $_ = "
> M0011
> spaceXYZabcdefh
> ";
> 
> $_ =~ s/(?:^|\n)(M\d+)\n([^\n]*)/A $1\nB $2/si;
> print $_;
> 
> Rob
> -----Original Message-----
> From: M z [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 02, 2002 2:08 PM
> To: Connie Chan
> Cc: [EMAIL PROTECTED]
> Subject: URGENT. Re: multi-line regex question,
> please help!
> 
> 
> Dear Connie, 
> 
> Inside the filehandle are the sample input
> line 1: M0011
> line 2: spaceXYZabcdefh
> 
> I am opening that up, reading it, trimming off
> prefacing spaces, as in line 2, and then the second
> expression is what I can't seem to get working.  The
> whole point is for me to know 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, then a newline,
> then
> a caret (presumable will match after a newline by
> virtue of the /m modifier???)than (.*) in $2 I
> thought
> would be the 2nd line...
> 
> Please help, anyone!!!!!
>  while (<I>) {
> > > s/^ +//gi;
> > > ###below, I think I count for M0011 in $1
> > > ###then, i thought by using the /m modifier,
> > > ###i could but a caret after the \n
> > > ###this doesn't work for me, please help
> > > ########
> > > $_ =~ s/^(M\d+)\n^(.*)/A $1\nB $2/mi;
> > > ########
> > > print O "$_";
> > > 
> > > 
> > > }
> 
> 
> M0011
>  XYZabcdefh
> 
> --- Connie Chan <[EMAIL PROTECTED]> wrote:
> > But what the content inside you file <I> ?
> > and what you suppose you to write to file <O> ?
> > Beside, seems you fotgot to close <O>;  close <I>
> =)
> > 
> > Smiley Connie =)
> > 
> > 
> > 
> > ----- Original Message ----- 
> > From: "M z" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, July 02, 2002 8:51 AM
> > Subject: multi-line regex question, please help!
> > 
> > 
> > > Dear all,
> > > 
> > > I am truly bewildered as to why I can't get this
> > > script to do what I want.  Namely, to get the
> > > multiline match.  Please help!!!! see section of
> > code
> > > surrounded by ######## for question area
> > > 
> > > sample input:  
> > > 
> > > M0011
> > >  XYZabcdefh
> > > 
> > > #!C:/perl/bin -w
> > > 
> > > die "Usage perl qup.pl <input> <output>" unless
> > @ARGV
> > > == 2;
> > > 
> > > my $in = $ARGV[0];
> > > my $out = $ARGV[1];
> > > 
> > > open(I, "$in");
> > > open(O, ">$out");
> > > 
> > > while (<I>) {
> > > s/^ +//gi;
> > > ###below, I think I count for M0011 in $1
> > > ###then, i thought by using the /m modifier,
> > > ###i could but a caret after the \n
> > > ###this doesn't work for me, please help
> > > ########
> > > $_ =~ s/^(M\d+)\n^(.*)/A $1\nB $2/mi;
> > > ########
> > > print O "$_";
> > > 
> > > 
> > > }
> > > 
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! - Official partner of 2002 FIFA World Cup
> > > http://fifaworldcup.yahoo.com
> > > 
> > > -- 
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > > 
> > > 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
[EMAIL PROTECTED]


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

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

Reply via email to