1Mixin::Linewise::WriterUss(e3r)Contributed Perl DocumentMaitxiionn::Linewise::Writers(3)
2
3
4

NAME

6       Mixin::Linewise::Writers - get linewise writers for strings and
7       filenames
8

VERSION

10       version 0.111
11

SYNOPSIS

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

PERL VERSION

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

EXPORTS

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

AUTHOR

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