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.110
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 SUPPORT

37       This module has the same support period as perl itself:  it supports
38       the two most recent versions of perl.  (That is, if the most recently
39       released version is v5.40, then this module should work on both v5.40
40       and v5.38.)
41
42       Although it may work on older versions of perl, no guarantee is made
43       that the minimum required version will not be increased.  The version
44       may be increased for any reason, and there is no promise that patches
45       will be accepted to lower the minimum required perl.
46

EXPORTS

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

AUTHOR

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