File::Edit - Edit a file by the line.
use File::Edit; $file = Edit->new("Filename");
$count = $file->grep("RegExp");
$line = $file->getline("RegExp" | Line Number);
$num = $file->delete("RegExp"); $line = $file->deleteline("RegExp" | Line Number); $file->insert("Insert String", Line Number);
This Perl-Module helps the programmer to edit a file line by line. The string to edit can be choosen by a regular expression.
The following methods are implemented:
$file = Edit->new("Filename");
Create a new File::Edit-Object and bind it to file ``Filename''.
$line
= $file->grep(``RegExp'');
The method get reads the file an returns the number of lines where the
regexp matches. $line
= $file->getline(``RegExp'' |
LineNr); If called with only a number, the method getline returns the
line
given by this number. If called with a regexp, it returns the FIRST
line
where the regexp matches.
$line = $file->delete("RegExp");
The method delete delete the phrases where the regexp matches. It will return the number of lines where it has delete the regexp.
$match = $file->deleteline("RegExp"| LineNr);
Delete all lines are matching the regexp. The return-value is the number of lines are deleted. If only called with a Number it will delete the line LineNr and returns it.
$file->insert("Insert String", Line Number);
This will insert the String ``Insert String'' at the line ``Line Number''. If given a ``Line Number'' of 0, the method will append the string to the file.
Martin Werthmoeller <software@werthmoeller.de>
perl(1).