in reply to Need a little help appending lines
What I'd suggest is that you create a new file with the desired content, and the move the new file to the place of the old file.
You could first read things that you want to append into @list, and then do the "real" operation:
use File::Copy; # for move() open my $of, '<', $old_file or die "Can't read $old_file: $!"; open my $nf, '>', $new_file or die "Can't write $new_file: $!"; my $line_number = 0; while (my $line = <$of>){ chomp $line; print $nf $line, $list[$line_number]; } close $nf; close $of; move $new_file, $old_file;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need a little help appending lines
by shmem (Chancellor) on Sep 11, 2007 at 22:47 UTC | |
by macrobat (Beadle) on Sep 12, 2007 at 21:11 UTC | |
by shmem (Chancellor) on Sep 12, 2007 at 21:23 UTC |