note
smalhotra
Couple of things:
<br>1. if <code>/matchdata/</code> has any capturing () than $name is pushed into @files for each ().
<br>2. When you do <code>@data = (<LDATA>)</code> you read the entire file into memory. A better way to do this would be:
<code>
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";
}
</code>
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.
<p><code>$will->code for @food or $$;</code>
279159
279200