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 version 0.004
11
13 package Your::Pkg;
14 use Mixin::Linewise::Writers -writers;
15
16 sub write_handle {
17 my ($self, $data, $handle) = @_;
18
19 $handle->print("datum: $_\n") for @$data;
20 }
21
22 Then:
23
24 use Your::Pkg;
25
26 Your::Pkg->write_file($data, $filename);
27
28 Your::Pkg->write_string($data, $string);
29
30 Your::Pkg->write_handle($data, $fh);
31
33 "write_file" and "write_string" are exported by default. Either can be
34 requested individually, or renamed. They are generated by
35 Sub::Exporter, so consult its documentation for more information.
36
37 Both can be generated with the option "method" which requests that a
38 method other than "write_handle" is called with the created IO::Handle.
39
40 write_file
41 Your::Pkg->write_file($data, $filename);
42
43 This method will try to open a new file with the given name. It will
44 then call "write_handle" with that handle.
45
46 Any arguments after $filename are passed along after to "write_handle".
47
48 write_string
49 my $string = Your::Pkg->write_string($data);
50
51 "write_string" will create a new IO::String handle, call "write_handle"
52 to write to that handle, and return the resulting string.
53
54 Any arguments after $data are passed along after to "write_handle".
55
57 Ricardo SIGNES <rjbs@cpan.org>
58
60 This software is copyright (c) 2008 by Ricardo SIGNES.
61
62 This is free software; you can redistribute it and/or modify it under
63 the same terms as the Perl 5 programming language system itself.
64
65
66
67perl v5.16.3 2013-06-18 Mixin::Linewise::Writers(3)