( categories: working with files )
Use the Tie::File module. This module makes a file look like a Perl array, each array element corresponds to a line of the file.
Tie::File is very efficient; instead of rewriting the entire file, it just rewrites what is necessary to apply the modification you specify.
Example:
#!/usr/bin/perl
use Tie::File;
#-- modify all ocurrences of 'HowTo' to 'how to'
tie @lines, 'Tie::File', "readme.txt" or die "Can't read file: $!\n";
foreach ( @lines )
{
s/HowTo/how to/g;
}
untie @lines;





