malloc has asked for the wisdom of the Perl Monks concerning the following question:
can we discuss how to do this with the -i modifier, if this is the right tool, or how other people handle this common task? Your wisdom is much appreciated. -mallocopen(FH,"myfile") or die "e tu brutus?\n"; # clobber it. while(<FH>) if ($_ =~ m/foo/){ $line = $_; $line =~ s/foo/bar/g; } else{ $line = $_; } $file = $file . $line; } open (FH,"> myfile") or die "e tu brutus?\n"; print FH $file
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl -i
by jepri (Parson) on May 24, 2001 at 19:40 UTC | |
|
Re: perl -i
by danger (Priest) on May 24, 2001 at 19:40 UTC | |
|
Re: perl -i
by chipmunk (Parson) on May 24, 2001 at 21:59 UTC | |
by malloc (Pilgrim) on May 24, 2001 at 22:57 UTC |