Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Simple file editing problems

by kabel (Chaplain)
on Oct 23, 2002 at 20:35 UTC ( #207523=note: print w/ replies, xml ) Need Help??


in reply to Simple file editing problems

in nearly every die () call: print out the $! scalar, which holds the "true" system error message.

please put the following two lines above your scripts:

use strict; use warnings;
explanation can be found here

this code example works for me:
use strict; use warnings; open (FILE, "<test.data") or die "open: $!"; my @file_contents = <FILE>; close (FILE); @file_contents = map {s/stefan/kabel/g; $_;} @file_contents; open (FILE, ">test.data") or die "open 2: $!"; print FILE $_ foreach (@file_contents); close (FILE);
not the nicest code, but who cares.


Comment on Re: Simple file editing problems
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2016-02-06 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (224 votes), past polls