1Mixin::Linewise::ReaderUss(e3r)Contributed Perl DocumentMaitxiionn::Linewise::Readers(3)
2
3
4
6 Mixin::Linewise::Readers - get linewise readers for strings and
7 filenames
8
10 package Your::Pkg;
11 use Mixin::Linewise::Readers -readers;
12
13 sub read_handle {
14 my ($self, $handle) = @_;
15
16 LINE: while (my $line = $handle->getline) {
17 next LINE if $line =~ /^#/;
18
19 print "non-comment: $line";
20 }
21 }
22
23 Then:
24
25 use Your::Pkg;
26
27 Your::Pkg->read_file($filename);
28
29 Your::Pkg->read_string($string);
30
31 Your::Pkg->read_handle($fh);
32
34 "read_file" and "read_string" are exported by default. Either can be
35 requested individually, or renamed. They are generated by
36 Sub::Exporter, so consult its documentation for more information.
37
38 Both can be generated with the option "method" which requests that a
39 method other than "read_handle" is called with the created IO::Handle.
40
41 read_file
42 Your::Pkg->read_file($filename);
43
44 If generated, the "read_file" export attempts to open the named file
45 for reading, and then calls "read_handle" on the opened handle.
46
47 Any arguments after $filename are passed along after to "read_handle".
48
49 read_string
50 Your::Pkg->read_string($string);
51
52 If generated, the "read_string" creates an IO::String handle from the
53 given string, and then calls "read_handle" on the opened handle.
54
55 Any arguments after $string are passed along after to "read_handle".
56
58 Bugs should be reported via the CPAN bug tracker at
59
60 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mixin-Linewise
61 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mixin-Linewise>
62
63 For other issues, or commercial enhancement or support, contact the
64 author.
65
67 Ricardo SIGNES, "E<lt>rjbs@cpan.orgE<gt>"
68
70 Copyright 2008, Ricardo SIGNES.
71
72 This program is free software; you may redistribute it and/or modify it
73 under the same terms as Perl itself.
74
75
76
77perl v5.12.0 2010-02-14 Mixin::Linewise::Readers(3)