1File::Slurper(3)      User Contributed Perl Documentation     File::Slurper(3)
2
3
4

NAME

6       File::Slurper - A simple, sane and efficient module to slurp a file
7

VERSION

9       version 0.013
10

SYNOPSIS

12        use File::Slurper 'read_text';
13        my $content = read_text($filename);
14

DESCRIPTION

16       This module provides functions for fast and correct slurping and
17       spewing. All functions are optionally exported. All functions throw
18       exceptions on errors, write functions don't return any meaningful
19       value.
20

FUNCTIONS

22   read_text($filename, $encoding, $crlf)
23       Reads file $filename into a scalar and decodes it from $encoding (which
24       defaults to UTF-8). If $crlf is true, crlf translation is performed.
25       The default for this argument is off. The special value 'auto' will set
26       it to a platform specific default value.
27
28   read_binary($filename)
29       Reads file $filename into a scalar without any decoding or
30       transformation.
31
32   read_lines($filename, $encoding, $crlf, $skip_chomp)
33       Reads file $filename into a list/array line-by-line, after decoding
34       from $encoding, optional crlf translation and chomping. It will always
35       use newline as separator.
36
37   write_text($filename, $content, $encoding, $crlf)
38       Writes $content to file $filename, encoding it to $encoding (which
39       defaults to UTF-8). It can also take a "crlf" argument that works
40       exactly as in read_text.
41
42   write_binary($filename, $content)
43       Writes $content to file $filename as binary data.
44
45   read_dir($dirname)
46       Open "dirname" and return all entries except "." and "..".
47

RATIONALE

49       This module tries to make it as easy as possible to read and write
50       files correctly and fast. The most correct way of doing this is not
51       always obvious (e.g. #83126
52       <https://rt.cpan.org/Public/Bug/Display.html?id=83126>), and just as
53       often the most obvious correct way is not the fastest correct way. This
54       module hides away all such complications behind an easy intuitive
55       interface.
56

DEPENDENCIES

58       This module has an optional dependency on PerlIO::utf8_strict.
59       Installing this will make UTF-8 encoded IO significantly faster, but
60       should not otherwise affect the operation of this module. This may
61       change into a dependency on the related Unicode::UTF8 in the future.
62

SEE ALSO

64       •   Path::Tiny
65
66           A minimalistic abstraction handling not only IO but also paths.
67
68       •   IO::All
69
70           An attempt to expose as many IO related features as possible via a
71           single API.
72
73       •   File::Slurp
74
75           This is a previous generation file slurping module. It has a number
76           of issues, as described here
77           <http://blogs.perl.org/users/leon_timmermans/2015/08/fileslurp-is-
78           broken-and-wrong.html>.
79
80       •   File::Slurp::Tiny
81
82           This was my previous attempt at a better file slurping module. It's
83           mostly (but not entirely) a drop-in replacement for File::Slurp,
84           which is both a feature (easy conversion) and a bug (interface
85           issues).
86

TODO

88       •   "open_text"/"open_binary"?
89
90       •   "drain_handle"?
91

AUTHOR

93       Leon Timmermans <leont@cpan.org>
94
96       This software is copyright (c) 2014 by Leon Timmermans.
97
98       This is free software; you can redistribute it and/or modify it under
99       the same terms as the Perl 5 programming language system itself.
100
101
102
103perl v5.34.0                      2022-01-21                  File::Slurper(3)
Impressum