This module uses the perl array to represent a file. each row of the file corresponds to an element of the array. The first behavior element is 0, and the second response is 1 ,...
The file itself is not actually loaded into the memory, and the operations on the array elements immediately work in the file. The greatest convenience is the ability to randomly specify the rows at the beginning and end of processing.
Basic usage:
Copy codeThe Code is as follows: use Tie: File;
Tie @ array, 'tie: file', filename or die ...;
$ Array [13] = 'blah'; # line 13 of the file is now 'blah'
Print $ array [42]; # display line 42 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
# Could t that they modify the file in the way you would perform CT
Push @ array, new recs ...;
My $ r1 = pop @ array;
Unshift @ array, new recs ...;
My $ r2 = shift @ array;
@ Old_recs = splice @ array, 3, 7, new recs ...;
Untie @ array; # all finished
For more functions, see the document on cpan.