GrandFather has asked for the wisdom of the Perl Monks concerning the following question:
Ok, I have <> and $^I down pat for inplace file edit where files are passed on the command line. Is there a neat way of doing the same for <filehandle> rather than something like this:
my $SomeFile = "delme.txt"; open inFile, "<$SomeFile" or die "Can't open $SomeFile for input: $!"; open outFile, ">~$SomeFile" or die "Can't open ~$SomeFile for output: +$!"; print outFile while <inFile>; close inFile; close outFile; unlink "$SomeFile.bak"; rename $SomeFile, "$SomeFile.bak"; rename "~$SomeFile", $SomeFile;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inplace file edit mark II
by kaif (Friar) on Jun 09, 2005 at 23:59 UTC | |
by GrandFather (Saint) on Jun 10, 2005 at 02:19 UTC |