1Mixin::Linewise::WriterUss(e3r)Contributed Perl DocumentMaitxiionn::Linewise::Writers(3)
2
3
4
6 Mixin::Linewise::Writers - get linewise writeers for strings and
7 filenames
8
10 package Your::Pkg;
11 use Mixin::Linewise::Writers -writers;
12
13 sub write_handle {
14 my ($self, $data, $handle) = @_;
15
16 $handle->print("datum: $_\n") for @$data;
17 }
18
19 Then:
20
21 use Your::Pkg;
22
23 Your::Pkg->write_file($data, $filename);
24
25 Your::Pkg->write_string($data, $string);
26
27 Your::Pkg->write_handle($data, $fh);
28
30 "write_file" and "write_string" are exported by default. Either can be
31 requested individually, or renamed. They are generated by
32 Sub::Exporter, so consult its documentation for more information.
33
34 Both can be generated with the option "method" which requests that a
35 method other than "write_handle" is called with the created IO::Handle.
36
37 write_file
38 Your::Pkg->write_file($data, $filename);
39
40 This method will try to open a new file with the given name. It will
41 then call "write_handle" with that handle.
42
43 Any arguments after $filename are passed along after to "write_handle".
44
45 write_string
46 my $string = Your::Pkg->write_string($data);
47
48 "write_string" will create a new IO::String handle, call "write_handle"
49 to write to that handle, and return the resulting string.
50
51 Any arguments after $data are passed along after to "write_handle".
52
54 Bugs should be reported via the CPAN bug tracker at
55
56 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mixin-Linewise
57 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mixin-Linewise>
58
59 For other issues, or commercial enhancement or support, contact the
60 author.
61
63 Ricardo SIGNES, "E<lt>rjbs@cpan.orgE<gt>"
64
66 Copyright 2008, Ricardo SIGNES.
67
68 This program is free software; you may redistribute it and/or modify it
69 under the same terms as Perl itself.
70
71
72
73perl v5.12.0 2010-02-14 Mixin::Linewise::Writers(3)