Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 the daffodils sway...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2016-12-03 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (52 votes). Check out past polls.