Thanks, Jeff. I read over the reference, but I guess I am missing the
syntax as I cannot get it to work properly. Can you point me to any
examples?

I found this example, but am having trouble translating it to my while
loop:

 perl -e '$_ = "{a\n{bb}\n{c\n\nc}\na\}"; m({.*})m; print $&'


Thanks again,
Jose

On Wed, 2004-01-14 at 18:37, Jeff Westman wrote:
> Jose Malacara <[EMAIL PROTECTED]> wrote:
> 
> > Can someone explain to me how to do multiline matching? I am
> > trying to extract three consecutive lines from a datafile
> > containing multiple records like this:
> 
> Check out 
> 
>     perldoc perlre
> 
> What you should do is look at the 'm' (multiple line) option.
> 
> 
> HTH
> 
> JW
> 
>  
> > Name: Bob
> > City: Austin
> > State: Texas
> > Address: 123 Whatever
> > Age: 46 
> > 
> > Name: Jose
> > City: Denver
> > State: Colorado
> > Address: 118 Mystreet
> > Age: 28 
> > 
> > 
> > 
> > This is what I have so far, but it doesn't seem to work:
> > 
> > #!/usr/bin/perl -w
> > open FILE, "<file1" or die "Can't open file!\n";
> > while (<FILE>){
> >   if ( /^Name: (.*)\nCity: (.*)\nState: (.*)/) {
> >    print "Match found!\n";  # ideally, I want to print the the
> > lines found
> >   }
> > }
> > close FILE;
> > 
> > But for some reason, it doesn't seem to like the (\n)'s in the
> > regex. Any help would be appreciated!
> > 
> > This is what I would like to return:
> > 
> > Name: Bob
> > City: Austin
> > State: Texas
> > 
> > Name: Jose
> > City: Denver
> > State: Colorado
> > 
> > 
> > Thanks in advance,
> > Jose
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
-- 
Jose Malacara
[EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to