Introduction to the module of Perl large file read processing _perl

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.