-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.html
More file actions
88 lines (63 loc) · 3.72 KB
/
docs.html
File metadata and controls
88 lines (63 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<html><head><title>File::BufferedInput</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
</head>
<body class='pod'>
<!--
generated by Pod::Simple::HTML v3.03,
using Pod::Simple::PullParser v2.02,
under Perl v5.008008 at Tue Jan 28 14:31:12 2014 GMT.
If you want to change this HTML document, you probably shouldn't do that
by changing it directly. Instead, see about changing the calling options
to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
then reconverting this document from the Pod source.
When in doubt, email the author of Pod::Simple::HTML for advice.
See 'perldoc Pod::Simple::HTML' for more info.
-->
<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>
<p>File::BufferedInput - Large and giant text file performance buffered reader.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>
<pre> use File::BufferedInput;
# create new object with default options, buffer size 20MB and ANSI text file
# file argument can be file name or file handle
my $fileobj = File::BufferedInput->new(file=>$filename);
# or create new object with custom options, set buffer size 50MB and UTF-8 text file
my $fileobj = File::BufferedInput->new(file=>$filename, buffer=>50_000_000, utf8=>1);
# or create new object then set the file name/handle
my $fileobj = File::BufferedInput->new();
$fileobj->file($filename_or_handle);
# now loop through all the text file lines straight forward
my $counter = 0;
while (my $line = $fileobj->line()) {#loop through the file lines sequentially
$counter++;
# print "$counter)- $line\n";
}
# start again from the begaining of the file
#$fileobj->rewind()
$fileobj->close(); # close the file and frees the memory used for the block
print "$counter lines found\n";</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p>This module solves the problem with reading large and huge text files in Perl. It is designed to read only block by block as needed. It does not load the whole file into memory, it only reads one block at a time and once the last sequential line reached, it reads the next block from the file and frees the previous block from memory, so at all times only one block of the file is kept in menory.</p>
<p>For example if you are reading a 2GB file, once you start reading lines from the file, the module reads the first block from the file on disk, while you loop through the lines, when you reach the line at the end of the read block, the module delete this block from memory and read the next block from the file on disk and parses it to lines and so on.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SEE_ALSO"
>SEE ALSO</a></h1>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>
<p>Ahmed Amin Elsheshtawy, <support@mewsoft.com> Website: http://www.mewsoft.com</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="COPYRIGHT_AND_LICENSE"
>COPYRIGHT AND LICENSE</a></h1>
<p>Copyright (C) 2014 by Ahmed Amin Elsheshtawy support@mewsoft.com <a href="http://www.mewsoft.com" class="podlinkurl"
>http://www.mewsoft.com</a></p>
<p>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>
<!-- end doc -->
</body></html>