Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Bug in script, regex help req extreme urgent

by jaredor (Curate)
on Mar 10, 2013 at 05:13 UTC ( #1022644=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Bug in script, regex help req extreme urgent
in thread Bug in script, regex help req extreme urgent

If you want a likely story to explain things, then here's mine: Your colleague wanted to change an entire module definition file "in place" but didn't want to use a temporary file.

On a Unix-type command line, you can do the same thing with

perl -pie 's/\b module \s+ OLD \b/module NEW/xms;' file_name

But back to your script. Your colleague didn't have to slurp the file into a single variable, he or she could have read the file into an array. The amount of memory taken up would have roughly been the same and the text processing could then have been done line-by-line.

I don't know what relevant CPAN modules are out there to make in-place text file processing easier, but I'd bet there are some. For your emergency need right now the other excellent answers in this thread should give you enough to deliver something.


Comment on Re^3: Bug in script, regex help req extreme urgent
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-12-26 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls