Acme-InputRecordSeparatorIsRegexp

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    Remember: the value of $/ is a string, not a regex. awk has to
    be better for something. :-)
 
This module attempts to get around that limitation, providing
a mechanism (using tied filehandles) to get the readline function
(and readline operator <...>) to define "lines" with respect to
a regular expression.
 
A common use case is to read a text file that you don't know
whether is uses Unix (\n), Windows/DOS (\r\n), or Mac (\r)
style line-endings, or even if it might contain all three.
 
Other use cases are files that contain multiple types of records
where a different sequence of characters is used to denote the
end of different types of records.
 
 
INSTALLATION
 
To install this module, run the following commands:

lib/Acme/InputRecordSeparatorIsRegexp.pm  view on Meta::CPAN

491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
Remember: the value of $/ is a string, not a regex. B<awk>
has to be better for something. :-)
 
=back
 
This module provides a mechanism to read records from a file
using a regular expression as a record separator.
 
A common use case for this module is to read a text file
that you don't know whether it uses Unix (C<\n>),
Windows/DOS (C<\r\n>), or Mac (C<\r>) style line-endings,
or even if it might contain all three. To properly parse
this file, you could tie its file handle to this package with
the appropriate regular expression:
 
    my $fh = Symbol::gensym;
    tie *$fh, 'Acme::InputRecordSeparatorIsRegexp', '\r\n|\r|\n';
    open $fh, '<', 'file-with-ambiguous-line-endings';
 
    @lines = <$fh>;
    # or

t/pod-coverage.t  view on Meta::CPAN

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use warnings FATAL => 'all';
 
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
    if $@;
 
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
    if $@;
 
all_pod_coverage_ok();



( run in 0.247 second using v1.01-cache-2.11-cpan-cba739cd03b )