in reply to Re: Re: Re: Checking Perl script on server
in thread Checking Perl script on server
Another side advantage of this is that if, for some reason, your script dies half way through then you still have our old file rather than a half written new file. hth.foreach (@files) { open(LDATA, "$_") || warn "File does not open: $!\n"; open(TMP, ">$_.tmp") || warn "File Write problem $_.tmp: $!\n"; while (<LDATA>) { s/OLD/NEW/gi; print TMP $_; } close(LDATA); close(TMP); rename("$_.tmp", "$_") or warn "Could not rename '$_.tmp' to '$_': + $!\n"; }
$will->code for @food or $$;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Checking Perl script on server
by waswas-fng (Curate) on Jul 30, 2003 at 22:14 UTC |