Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Answer: Apply regex to entire file, not just individual lines ?

by vxp (Pilgrim)
on Aug 16, 2002 at 16:14 UTC ( #190695=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > Apply regex to entire file, not just individual lines ? - Answer contributed by vxp

You might not want to have your WHOLE file in one variable. Depending on the size of the file, it could eat a LOT of your memory. From my own experience, it is usually enough for me to do $/ = '\n\n' and then the linebreak is 2 new lines, not one. I was parsing a bounce file when I was doing this, which was about 300megs in size, daily. thats a LONG 300mb line. $/ = '\n\n'; took care of it. i ended up with having.. smaller big lines, and was able to do what I wanted to do without consuming a lot of RAM.

  • Comment on Answer: Apply regex to entire file, not just individual lines ?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-02-19 22:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (293 votes). Check out past polls.