Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: multi-line parsing

by Bloodnok (Vicar)
on Mar 31, 2009 at 18:32 UTC ( #754496=note: print w/replies, xml ) Need Help??


in reply to multi-line parsing

Try using the range operator - something like i.e. untested...
use warnings; use strict; use autodie; open INF, "<$file"; while (<INF>){ if(/First line of text$/ ... /in the third line I have (\d*\.\d*)$ +/) { push @array, $1 if $1; } }
Note the use of both strictures and autodie - the latter causing the snippet to die if open() fails.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: multi-line parsing
by amit223 (Initiate) on Mar 31, 2009 at 19:05 UTC

    Thank you one and all.

    Bloodnok, I have a small issue there:

    How do I get away if I see a number in the second line, but would like to grab the number in the line3. Sorry, should have been clear

    Thank you again

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://754496]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2020-08-13 00:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (68 votes). Check out past polls.

    Notices?