Array::LineReader

Access lines of a file via an array
Download

Array::LineReader Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Bjoern Holsten
  • Publisher web site:
  • http://search.cpan.org/~bholsten/

Array::LineReader Tags


Array::LineReader Description

Access lines of a file via an array Array::LineReader is a Perl module that gives you the possibility to access lines of some file by the elements of an array. This modul inherites methods from Tie::Array (see Tie::Array). You save a lot of memory, because the file's content is read only on demand, i.e. in the case you access an element of the array. The offset and length of all the lines is hold in memory as long as you tie your array.The underlying file is opened for reading in binary mode. (Yes, there are some OSs, that make a difference in interpreting the EOL-sequence, i.e. End-Of-Line and the EOF-character, i.e. End-Of-File what is the character "x1A"). The bytes read are neigther translated nor suppressed.Lines are build up to and including the EOL-sequence. The EOL-sequence is assumed to be "x0Dx0A" or "x0Ax0D" or "x0D" or "x0A".The file is not closed until you untie the array.SYNOPSIS use Array::LineReader; my @lines; # Get the content of every line as an element of @lines: tie @lines, 'Array::LineReader', 'filename'; print scalar(@lines); # number of lines in the file print $lines; # content of the first line print $lines; # content of the last line ... # Get the offset and content of every line as array reference via the elements of @lines: tie @lines, 'Array::LineReader', 'filename', result=>[]; print scalar(@lines); # number of lines in the file print $lines->,":",$lines->; # offset and content of the 5th line print $lines->,":",$lines->; # offset and content of the last line ... # Get the offset and content of every line as hash reference via the elements of @lines: tie @lines, 'Array::LineReader', 'filename', result=>{}; print scalar(@lines); # number of lines in the file print $lines->{OFFSET},":",$lines->{CONTENT}; # offset and content of the 4th line print $lines->{OFFSET},":",$lines->{CONTENT}; # offset and content of the last line ... Requirements: · Perl


Array::LineReader Related Software