in reply to How do I save changes made to a file

Tie::File could be used to automatically save changes to the file. This is also useful if the file isn't small enough to fit into memory all at once.

#!/usr/bin/perl use Tie::File; my $filename = 'foo.dat'; tie @array, 'Tie::File', $filename or die "Cannot open $filename\n"; $array[2] = '#'.$array[2]; $array[3] = '#'.$array[3];

This will comment out lines 3 and 4 in the file "foo.dat" and automatically save changes.

- Neil