Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 wandering the Monastery: (14)
As of 2014-11-24 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (143 votes), past polls