Acme-InputRecordSeparatorIsRegexp
view release on metacpan or search on metacpan
lib/Acme/InputRecordSeparatorIsRegexp.pm view on Meta::CPAN
%opts,
handle => $handle,
rs => $rs,
records => [],
buffer => ''
}, $pkg;
$self->_compile_rs;
return $self;
}
# We abuse the PerlIO layers syntax to attach
# a regexp specification to a filehandle. This
# function extracts an ':irs(REGEXP)' layer from
# a string.
sub _extract_irs {
my ($mode) = @_;
my $irs = "";
my $p0 = index($mode,":irs(");
my $p1 = $p0 + 5;
my $nest = 1;
lib/Acme/InputRecordSeparatorIsRegexp.pm view on Meta::CPAN
L<< C<qr/.../>|"Quote and quote-like operators"/perlop >> notation)
containing the regular expression
you want to use for a file's line endings. Also see the convenience
method L<"open"> for an alternate way to obtain a file handle with
the features of this package.
=head1 FUNCTIONS
=head2 open
Another way of using this package to attach a regular expression
to the input record separator of a file handle, available since
v0.04, is to import this package's C<open> function and to
specify an C<:irs(...)> I<pseudo-layer>.
use Acme::InputRecordSeparatorIsRegexp 'open';
$result = open FILEHANDLE, "<:irs(REGEXP)", EXPR
$result = open FILEHANDLE, "<:irs(REGEXP)", EXPR, LIST
$result = open FILEHANDLE, "<:irs(REGEXP)", REFERENCE
$result = open my $fh, "<:irs(\r|\n|\r\n)", "ambiguous-line-endings.txt"
( run in 0.297 second using v1.01-cache-2.11-cpan-88abd93f124 )