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

NAME

6       File::LoadLines - Load lines from file
7

SYNOPSIS

9           use File::LoadLines;
10
11           my @lines = loadlines("mydata.txt");
12           ...
13

DESCRIPTION

15       File::LoadLines provides an easy way to load the contents of a text
16       file into an array of lines. It is intended for relatively small files
17       like config files that are often produced by weird tools (and users).
18
19       It automatically handles ASCII, Latin and UTF-8 text.  When the file
20       has a BOM, it handles UTF-8, UTF-16 LE and BE, and UTF-32 LE and BE.
21
22       Recognized line terminators are NL (Unix, Linux), CRLF (DOS, Windows)
23       and CR (Mac)
24

EXPORT

26   loadlines

FUNCTIONS

28   loadlines
29           my @lines = loadlines("mydata.txt");
30           my @lines = loadlines("mydata.txt", $options);
31
32       Basically, the file is opened, read, decoded and split into lines that
33       are returned in the result array. Line terminators are removed.
34
35       In scalar context, returns an array reference.
36
37       The first argument may be the name of a file, an opened file handle, or
38       a reference to a string that contains the data.
39
40       The second argument can be used to influence the behaviour.  It is a
41       hash reference of option settings.
42
43       Note that loadlines() is a slurper, it reads the whole file into memory
44       and requires temporarily memory for twice the size of the file.
45
46       split
47           Enabled by default.
48
49           If set to zero, the data is not split into lines but returned as a
50           single string.
51
52       chomp
53           Enabled by default.
54
55           If set to zero, the line terminators are not removed from the
56           resultant lines.
57

SEE ALSO

59       There are currently no other modules that handle BOM detection and line
60       splitting.
61
62       I have a faint hope that Perl6 will deal with this transparently, but I
63       fear the worst.
64

AUTHOR

66       Johan Vromans, "<JV at cpan.org>"
67

SUPPORT AND DOCUMENTATION

69       Development of this module takes place on GitHub:
70       https://github.com/sciurius/perl-File-LoadLines.
71
72       You can find documentation for this module with the perldoc command.
73
74           perldoc File::LoadLines
75
76       Please report any bugs or feature requests using the issue tracker on
77       GitHub.
78
80       Copyright 2018 Johan Vromans, all rights reserved.
81
82       This program is free software; you can redistribute it and/or modify it
83       under the same terms as Perl itself.
84
85
86
87perl v5.30.1                      2020-02-28                File::LoadLines(3)
Impressum