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.108
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

EXPORTS

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       If given a "binmode" option, any "write_file" type functions will use
41       that as an IO layer, otherwise, the default is "encoding(UTF-8)".
42
43         use Mixin::Linewise::Writers -writers => { binmode => "raw" };
44         use Mixin::Linewise::Writers -writers => { binmode => "encoding(iso-8859-1)" };
45
46   write_file
47         Your::Pkg->write_file($data, $filename);
48         Your::Pkg->write_file($data, $options, $filename);
49
50       This method will try to open a new file with the given name.  It will
51       then call "write_handle" with that handle.
52
53       An optional hash reference may be passed before $filename with options.
54       The only valid option currently is "binmode", which overrides any
55       default set from "use" or the built-in "encoding(UTF-8)".
56
57       Any arguments after $filename are passed along after to "write_handle".
58
59   write_string
60         my $string = Your::Pkg->write_string($data);
61         my $string = Your::Pkg->write_string(\%option, $data);
62
63       "write_string" will create a new handle on the given string, then call
64       "write_handle" to write to that handle, and return the resulting
65       string.  Because handles on strings must be octet-oriented, the string
66       will contain octets.  It will be opened in the default binmode
67       established by importing.  (See "EXPORTS", above, and the options,
68       below.)
69
70       Any arguments after $data are passed along after to "write_handle".
71
72       Like "write_file", this method can take a leading hashref with one
73       valid argument: "binmode".
74

AUTHOR

76       Ricardo SIGNES <rjbs@cpan.org>
77
79       This software is copyright (c) 2008 by Ricardo SIGNES.
80
81       This is free software; you can redistribute it and/or modify it under
82       the same terms as the Perl 5 programming language system itself.
83
84
85
86perl v5.30.0                      2019-08-23       Mixin::Linewise::Writers(3)
Impressum