Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Problem with String replace in file

by meraxes (Friar)
on Oct 22, 2007 at 17:36 UTC ( #646511=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Problem with String replace in file
in thread Problem with String replace in file

I suspect your problem is that you are writing back to the filehandle IN when you (presumably) only opened it for read.

open( IN, '<', $filename ); # input open( OUT, '>', 'newfilename.txt' ); # output while ( <IN> ) { s/\|\|/|\\N|/g; print OUT; } close IN; close OUT;
--
meraxes


Comment on Re^3: Problem with String replace in file
Select or Download Code
Re^4: Problem with String replace in file
by philosophia (Sexton) on Oct 22, 2007 at 18:17 UTC
    This was correct, thank you. || is replaced by |\N| throughtout newfilename.txt.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2015-04-19 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who makes your decisions?







    Results (358 votes), past polls