Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Simple Search and Replace?

by OM_Zen (Scribe)
on Mar 26, 2003 at 18:10 UTC ( #246022=note: print w/ replies, xml ) Need Help??


in reply to Simple Search and Replace?

Hi ,

The assignment of file contents to an array surely depends on the size of the file .The file , if it has a larger size will consume whole of the memory either dumping core or exiting out with some untrappable error. Hence people tend to use while to read and print in the write file

while (<readthefile>) $_ =~ s///g; print WriteData "$_"; print "$/"; }


The read os data if it is small in size you could set  $/ = undef; and slurp the file contents to a ascalar variable itself and then do the regular expression on it .


Comment on Re: Simple Search and Replace?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-08-23 11:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls