File::Data v1.20 released

File::Data – interface to file data

DESCRIPTION

Wraps all the accessing of a file into a convenient set of calls for reading and writing data, including a simple regex interface.

Note that the file needs to exist prior to using this module!

See new()

SYNOPSIS

use strict;
my $o_dat = File::Data->new('./t/example');
$o_dat->write("complete file contents\n");
$o_dat->prepend("first line\n"); # line 0
$o_dat->append("original second (last) line\n");
$o_dat->insert(2, "new second line\n"); # inc. zero!
$o_dat->replace('line', 'LINE');
print $o_dat->READ;

Or, perhaps more seriously :-}

my $o_sgm = File::Data->new('./sgmlfile');
print "new SGML data: ".$o_sgm->REPLACE(
    '\<\s*((?i)tag)\s*\>\s*((?s).*)\s*\<\s*((?i)\s*\/\s*tag)\s*\>',
    qq|<tag>key="val"</tag>|,
) if $o_sgm;

See METHODS and EXAMPLES.

Find this content useful? Share it with your friends or comment below!

Leave a Comment