line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyData2::Storage::File::Linewise; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1304
|
use 5.008001; |
|
2
|
|
|
|
|
4
|
|
4
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
54
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
5
|
use base qw(AnyData2::Storage::File); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
352
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
8
|
use IO::File (); |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
304
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
AnyData2::Storage::File::Linewise - AnyData2 line oriented file storage |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 read |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $buf = $stor->read() |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Use binmode for characters as synonymous for bytes. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub read |
30
|
|
|
|
|
|
|
{ |
31
|
5
|
|
|
5
|
1
|
4
|
my $self = shift; |
32
|
5
|
|
|
|
|
10
|
$self->{fh}->clearerr; |
33
|
5
|
|
|
|
|
81
|
my $buf = $self->{fh}->getline; |
34
|
5
|
50
|
|
|
|
111
|
$self->{fh}->error and die "Can't read from $self->{filename}: $!"; |
35
|
5
|
100
|
|
|
|
8
|
defined $buf or return; |
36
|
4
|
|
|
|
|
4
|
chomp $buf; |
37
|
4
|
|
|
|
|
7
|
$buf; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 write |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$stor->write($buf) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Writes the buf out |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub write |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
0
|
1
|
|
my ( $self, $buf ) = @_; |
51
|
0
|
0
|
|
|
|
|
$self->{fh}->say($buf) or die "Can't write to $self->{filename}: $!"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Copyright 2015,2016 Jens Rehsack. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
59
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
60
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
65
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
66
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
69
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
72
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
73
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
74
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
75
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
76
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
77
|
|
|
|
|
|
|
direct or contributory patent infringement, then this License |
78
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
81
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
82
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
83
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
84
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
85
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
86
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
87
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |