[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] How to modify a text file

Another newbie-question:

What is the standard way of modifying a text file with Perl? I 
experimented a bit with all the modifiers in front of the filename in the 
"open"-function, but I always ended up opening the file TWICE: 

open (IN, "file.txt");
$_ = join "",@all_lines;

#(Do some operations on $_ here)

open (OUT, ">file.txt");
print OUT;

I can't believe that there is no other way of doing it. Another thing 
that makes me nervous about my approach is that there is a moment in the 
script (after the second "open") when the contents of my file is alrady 
erased and lives only in the $_-Variable...

Thanks for any suggestions!


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org