Ioannis Tambouras > PerlIO-via-Skip > PerlIO::via::Skip

Download:
PerlIO-via-Skip-0.06.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Module Version: 0.04   Source  

NAME ^

PerlIO::via::Skip - PerlIO layer for skipping lines

SYNOPSIS ^

  use PerlIO::via::Skip;

  $ENV{ viaSKIP} = { start=>'Fiat', end=>'Reno' };
  open my $i ,'<:via(Skip)', 'cars'  or die $!;


  $ENV{ viaSKIP} = { start          =>  'Fiat'       , 
                     end            =>   undef       ,
                     maxlines       =>     10        ,
                     after          =>      0        ,
                     skippatterns   =>   [qw( a e )] ,
                     skipcomments   =>      1        ,
                     skipblanklines =>      1        , }
  open my $i ,'<:via(Skip)', 'cars'  or die $!;

DESCRIPTION ^

This module implements a PerlIO layer that discards lines from IO streams. By default, all lines are accepted and passed-through as if no filters are present. Input filters discard input lines, and output filters discard output lines; therefore, input lines (that meet user's criteria) are excluded from input, and in a similar manner when specified, output lines are omitted from output.

 The code is re-entrant. Multiple filters can be
stacked together without interfering with one another.
These filters were designed for read, write, and append handles
( 'r', 'w', 'a'), but will refuse installation
for read-write mode.

CONFIGURATION ^

In order to stay re-entrant, configuration is done by setting the global variable $ENV{viaSKIP} . While other PerlIO modules are usually configured via class variables through import(), I choose to sacrifice pretty syntax for data integrity. During the call to open(), or during binmode(), the filter reads its configuration from the $ENV{viaSKIP} variable; since this is a dynamic value, you probably want to change it before the open(), or binmode() if other filters should read a different configurations.

  The env variable 'viaSKIP' takes the form of a hash reference. 
  For example: $ENV{ viaSKIP } = { maxlines=> 10, start=>'apple' };

Where 'maxlines', and 'start' are configuration parameters. Here are all the parameters that allow you to alter the characteristics of the filter:

 maxlines        limit the maximum number of input (or output) lines
 skippatterns    skip lines containing one of these patterns
 skipblanklines  skip whitespace lines
 skipcomments    skip lines with (leading) comments
 start           Start a bipolar vibrator. Skip leading lines
                 until a certain pattern
 end             End a bipolar vibrator. Skip remaining lines
                 after a certain pattern.
 after           Used with a bipolar vibrator. Skip more leading lines,
                 after you find the start pattern.

EXPORT

None by default.

SEE ALSO ^

Consult the documentation of the range operator, when in scalar context for a description on how the bipolar vibrator operates. Note, however, that in this implementation the bipolar is designed for only full one cycle. (Will need to change the range operator from a a m?? regex to a m// regex if you need infinite cycles.)

AUTHOR ^

Ioannis Tambouras <ioannis@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005 by Ioannis Tambouras

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: