The module uses a Perl array to represent a file, each row of the file corresponds to an element of the array, the first behavior element 0, the second back is 1, ...
The file itself is not actually loaded into memory, and the operation of the array element immediately acts on the file. The most convenient is that you can specify any number of lines at the end of the process.
Basic usage:
Copy Code code as follows:
Use Tie::file;
Tie @array, ' tie::file ', filename or die ...;
$array [+] = ' blah '; # Line of the ' the ', ' Now ' blah '
Print $array [42]; # Display line of the file
$n _recs = @array; # How many records are in the file?
$ #array-= 2; # Chop two records off the end
for (@array) {
s/perl/perl/g; # Replace Perl with Perl everywhere in the file
}
# These are just like regular push, pop, unshift, shift, and splice
# Except that they modify the ' file in ' way you would expect
Push @array, new RECs ...;
My $r 1 = Pop @array;
Unshift @array, new RECs ...;
My $r 2 = Shift @array;
@old_recs = Splice @array, 3, 7, new RECs ...;
Untie @array; # all finished
More multi-function please refer to the documentation on CPAN.