1Mixin::Linewise::ReaderUss(e3r)Contributed Perl DocumentMaitxiionn::Linewise::Readers(3)
2
3
4

NAME

6       Mixin::Linewise::Readers - get linewise readers for strings and
7       filenames
8

VERSION

10       version 0.111
11

SYNOPSIS

13         package Your::Pkg;
14         use Mixin::Linewise::Readers -readers;
15
16         sub read_handle {
17           my ($self, $handle) = @_;
18
19           LINE: while (my $line = $handle->getline) {
20             next LINE if $line =~ /^#/;
21
22             print "non-comment: $line";
23           }
24         }
25
26       Then:
27
28         use Your::Pkg;
29
30         Your::Pkg->read_file($filename);
31
32         Your::Pkg->read_string($string);
33
34         Your::Pkg->read_handle($fh);
35

PERL VERSION

37       This module should work on any version of perl still receiving updates
38       from the Perl 5 Porters.  This means it should work on any version of
39       perl released in the last two to three years.  (That is, if the most
40       recently released version is v5.40, then this module should work on
41       both v5.40 and v5.38.)
42
43       Although it may work on older versions of perl, no guarantee is made
44       that the minimum required version will not be increased.  The version
45       may be increased for any reason, and there is no promise that patches
46       will be accepted to lower the minimum required perl.
47

EXPORTS

49       "read_file" and "read_string" are exported by default.  Either can be
50       requested individually, or renamed.  They are generated by
51       Sub::Exporter, so consult its documentation for more information.
52
53       Both can be generated with the option "method" which requests that a
54       method other than "read_handle" is called with the created IO::Handle.
55
56       If given a "binmode" option, any "read_file" type functions will use
57       that as an IO layer, otherwise, the default is "utf8_strict".
58
59         use Mixin::Linewise::Readers -readers => { binmode => "raw" };
60         use Mixin::Linewise::Readers -readers => { binmode => "encoding(iso-8859-1)" };
61
62   read_file
63         Your::Pkg->read_file($filename);
64         Your::Pkg->read_file(\%options, $filename);
65
66       If generated, the "read_file" export attempts to open the named file
67       for reading, and then calls "read_handle" on the opened handle.
68
69       An optional hash reference may be passed before $filename with options.
70       The only valid option currently is "binmode", which overrides any
71       default set from "use" or the built-in "utf8_strict".
72
73       Any arguments after $filename are passed along after to "read_handle".
74
75   read_string
76         Your::Pkg->read_string($string);
77         Your::Pkg->read_string(\%option, $string);
78
79       If generated, the "read_string" creates a handle on the given string,
80       and then calls "read_handle" on the opened handle.  Because handles on
81       strings must be octet-oriented, the string must contain octets.  It
82       will be opened in the default binmode established by importing.  (See
83       "EXPORTS", above.)
84
85       Any arguments after $string are passed along after to "read_handle".
86
87       Like "read_file", this method can take a leading hashref with one valid
88       argument: "binmode".
89

AUTHOR

91       Ricardo SIGNES <cpan@semiotic.systems>
92
94       This software is copyright (c) 2008 by Ricardo SIGNES.
95
96       This is free software; you can redistribute it and/or modify it under
97       the same terms as the Perl 5 programming language system itself.
98
99
100
101perl v5.36.0                      2023-01-20       Mixin::Linewise::Readers(3)
Impressum