File::Edit.3pm

Langue: en

Version: 2000-04-21 (mandriva - 01/05/08)

Section: 3 (Bibliothèques de fonctions)

NAME

File::Edit - Edit a file by the line.

SYNOPSIS

  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);
 
 

DESCRIPTION

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.

AUTHOR

Martin Werthmoeller, software@werthmoeller.de

SEE ALSO

perl(1). Copyright (c) 2000 Martin Werthmoeller. All right reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.