in reply to Re: writing to top of a file
in thread writing to top of a file
You said: The example above is ok, but if the file is very large, you might want to use join the data.
Joining the data will not eleminate the problem, it will only delay it (and not by much for that matter). If the file is very large, use:
Code to check success of operations is not included for readabilityuse File::Temp qw/tempfile/; open $FIN, "<$file1" or die .... my ($fh, $fname) = tempfile(); print $fh "FIRST LINE\n"; print $fh $_ while <$FIN>; close $FIN; close $fh; rename $fname, $file1;
Aziz,,,
Update: Thanks runrig for the comment. The point is the same, don't read all data into memory when moving data from file to file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: writing to top of a file
by runrig (Abbot) on Aug 06, 2001 at 22:46 UTC |