Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: file reading issues

by bofh_of_oz (Hermit)
on Aug 03, 2005 at 19:13 UTC ( #480604=note: print w/replies, xml ) Need Help??


in reply to file reading issues

A regex will parse the file just fine. Just grab the whole file into a variable, then do this:

#Sample data, multiline $line = "<!-- Begin -->Line one\nLine two\nthree\nfour<!-- End -->"; #process them $line =~ s/<!-- Begin -->(.*)<!-- End -->/$1/s; print $line;

I tried to do the same while reading the file line-by-line... The code was so ugly that I simply recommend to read in the whole file at once and do a multiline regexp above...

HTH

--------------------------------
An idea is not responsible for the people who believe in it...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://480604]
help
Chatterbox?
[LanX]: Enemies_of_the_Peo ple
[LanX]: Enemies_of_the_Peo ple
[LanX]: and https://en. wikipedia.org/ wiki/Enemy_of_the_ people#Recent_usag e

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2017-03-27 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.