| 1 | 59 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | package IO::All::File; | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 59 | ▶ | use IO::All::Filesys -base; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 59 | ▶ | use IO::All -base; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 59 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 59 | ▶ | use File::Copy (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | #=============================================================================== | ||||||||||||||||||||||||||||||||
| 10 | 59 | const type => 'file'; | |||||||||||||||||||||||||||||||
| 11 | 59 | field tied_file => undef; | |||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | #=============================================================================== | ||||||||||||||||||||||||||||||||
| 14 | sub file { | ||||||||||||||||||||||||||||||||
| 15 | 333 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
file: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 16 | 333 | bless $self, __PACKAGE__; | |||||||||||||||||||||||||||||||
| 17 | # should we die here if $self->name is already set and there are args? | ||||||||||||||||||||||||||||||||
| 18 | 333 | ▶ | if (@_ && @_ > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
@_ and @_ > 1
MC/DC100%2/2
@_ and @_ > 1
@_
@_ > 1
Truth table100%3/3
A and B
A= @_B= @_ > 1
| |||||||||||||||||||||||||||||||||
| 19 | 9 | $self->name( $self->_spec_class->catfile( @_ ) ) | |||||||||||||||||||||||||||||||
| 20 | } elsif (@_) { | ||||||||||||||||||||||||||||||||
| 21 | 304 | $self->name($_[0]) | |||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||
| 23 | 333 | return $self->_init; | |||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | sub file_handle { | ||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
file_handle: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 28 | 0 | bless $self, __PACKAGE__; | |||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $self->_handle(shift) if @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 30 | 0 | return $self->_init; | |||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | #=============================================================================== | ||||||||||||||||||||||||||||||||
| 34 | sub assert_filepath { | ||||||||||||||||||||||||||||||||
| 35 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
assert_filepath: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 36 | 4 | ▶ | my $name = $self->pathname | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 37 | or return; | ||||||||||||||||||||||||||||||||
| 38 | 4 | my $directory; | |||||||||||||||||||||||||||||||
| 39 | 4 | (undef, $directory) = File::Spec->splitpath($self->pathname); | |||||||||||||||||||||||||||||||
| 40 | 4 | $self->_assert_dirpath($directory); | |||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | sub assert_open_backwards { | ||||||||||||||||||||||||||||||||
| 44 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
assert_open_backwards: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 45 | 8 | ▶ | return if $self->is_open; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | 2 | require File::ReadBackwards; | |||||||||||||||||||||||||||||||
| 47 | 2 | my $file_name = $self->pathname; | |||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | my $io_handle = File::ReadBackwards->new($file_name) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | or $self->throw("Can't open $file_name for backwards:\n$!"); | ||||||||||||||||||||||||||||||||
| 50 | 2 | $self->io_handle($io_handle); | |||||||||||||||||||||||||||||||
| 51 | 2 | $self->is_open(1); | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | sub _assert_open { | ||||||||||||||||||||||||||||||||
| 55 | 218 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_assert_open: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 56 | 218 | ▶ | return if $self->is_open; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 57 | 101 | ▶ | $self->mode(shift) unless $self->mode; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 58 | 101 | $self->open; | |||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | sub assert_tied_file { | ||||||||||||||||||||||||||||||||
| 62 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
assert_tied_file: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 63 | 6 | ▶ | return $self->tied_file || do { | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->tied_file || do {
eval {
do {
require Tie::File
}
};
$self->throw("Tie::File required for file array operations:\n$@") if $@;
my $array_ref = do {
my @array;
\@array
};
my $name = $self->pathname;
my(@options) = $self->_rdonly ? ('mode', 0) : ();
push @options, ('recsep', $self->separator);
tie @$array_ref, 'Tie::File', $name, @options;
$self->throw("Can't tie 'Tie::File' to '${name}':\n$!") unless tied @$array_ref;
$self->tied_file($array_ref)
}
MC/DC0%0/2
$self->tied_file || do {
eval {
do {
require Tie::File
}
};
$self->throw("Tie::File required for file array operations:\n$@") if $@;
my $array_ref = do {
my @array;
\@array
};
my $name = $self->pathname;
my(@options) = $self->_rdonly ? ('mode', 0) : ();
push @options, ('recsep', $self->separator);
tie @$array_ref, 'Tie::File', $name, @options;
$self->throw("Can't tie 'Tie::File' to '${name}':\n$!") unless tied @$array_ref;
$self->tied_file($array_ref)
}
$self->tied_file
do {
eval {
do {
require Tie::File
}
};
$self->throw("Tie::File required for file array operations:\n$@") if $@;
my $array_ref = do {
my @array;
\@array
};
my $name = $self->pathname;
my(@options) = $self->_rdonly ? ('mode', 0) : ();
push @options, ('recsep', $self->separator);
tie @$array_ref, 'Tie::File', $name, @options;
$self->throw("Can't tie 'Tie::File' to '${name}':\n$!") unless tied @$array_ref;
$self->tied_file($array_ref)
}
Truth table66%2/3
A || B
A= $self->tied_fileB= do {
eval {
do {
require Tie::File
}
};
$self->throw("Tie::File required for file array operations:\n$@") if $@;
my $array_ref = do {
my @array;
\@array
};
my $name = $self->pathname;
my(@options) = $self->_rdonly ? ('mode', 0) : ();
push @options, ('recsep', $self->separator);
tie @$array_ref, 'Tie::File', $name, @options;
$self->throw("Can't tie 'Tie::File' to '${name}':\n$!") unless tied @$array_ref;
$self->tied_file($array_ref)
}
| |||||||||||||||||||||||||||||||||
| 64 | 5 | eval {require Tie::File}; | |||||||||||||||||||||||||||||||
| 65 | 5 | ▶ | $self->throw("Tie::File required for file array operations:\n$@") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | if $@; | ||||||||||||||||||||||||||||||||
| 67 | 5 | my $array_ref = do { my @array; \@array }; | |||||||||||||||||||||||||||||||
| 68 | 5 | my $name = $self->pathname; | |||||||||||||||||||||||||||||||
| 69 | 5 | ▶ | my @options = $self->_rdonly ? (mode => O_RDONLY) : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | 5 | push @options, (recsep => $self->separator); | |||||||||||||||||||||||||||||||
| 71 | 5 | tie @$array_ref, 'Tie::File', $name, @options; | |||||||||||||||||||||||||||||||
| 72 | 5 | ▶ | $self->throw("Can't tie 'Tie::File' to '$name':\n$!") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | unless tied @$array_ref; | ||||||||||||||||||||||||||||||||
| 74 | 5 | $self->tied_file($array_ref); | |||||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | sub open { | ||||||||||||||||||||||||||||||||
| 79 | 116 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
open: called CC=10 SCAR=24.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 80 | 116 | $self->is_open(1); | |||||||||||||||||||||||||||||||
| 81 | 116 | ▶ | $self->assert_filepath if $self->_assert; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 82 | 116 | my ($mode, $perms) = @_; | |||||||||||||||||||||||||||||||
| 83 | 116 | ▶ | $self->mode($mode) if defined $mode; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | 116 | ▶ | $self->mode('<') unless defined $self->mode; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 85 | 116 | ▶ | $self->perms($perms) if defined $perms; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 86 | 116 | my @args = ($self->mode); | |||||||||||||||||||||||||||||||
| 87 | 116 | ▶ | push @args, $self->perms if defined $self->perms; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | 116 | ▶ | if (defined $self->pathname) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 89 | 116 | $self->io_handle(IO::File->new); | |||||||||||||||||||||||||||||||
| 90 | 116 | ▶ | $self->io_handle->open($self->pathname, @args) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | or $self->throw($self->open_msg); | ||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | ▶ | elsif (defined $self->_handle and | |||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $self->_handle and not $self->io_handle->opened
MC/DC0%0/2
defined $self->_handle and not $self->io_handle->opened
defined $self->_handle
not $self->io_handle->opened
Truth table0%0/3
A and not(B)
A= defined $self->_handleB= not $self->io_handle->opened
| |||||||||||||||||||||||||||||||||
| 94 | not $self->io_handle->opened | ||||||||||||||||||||||||||||||||
| 95 | ) { | ||||||||||||||||||||||||||||||||
| 96 | # XXX Not tested | ||||||||||||||||||||||||||||||||
| 97 | 0 | $self->io_handle->fdopen($self->_handle, @args); | |||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | 115 | $self->set_lock; | |||||||||||||||||||||||||||||||
| 100 | 115 | $self->_set_binmode; | |||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub exists { -f shift->pathname } | ||||||||||||||||||||||||||||||
|
Subroutine
exists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | 59 | my %mode_msg = ( | |||||||||||||||||||||||||||||||
| 106 | '>' => 'output', | ||||||||||||||||||||||||||||||||
| 107 | '<' => 'input', | ||||||||||||||||||||||||||||||||
| 108 | '>>' => 'append', | ||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||
| 110 | sub open_msg { | ||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
open_msg: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | my $name = defined $self->pathname | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 113 | ? " '" . $self->pathname . "'" | ||||||||||||||||||||||||||||||||
| 114 | : ''; | ||||||||||||||||||||||||||||||||
| 115 | my $direction = defined $mode_msg{$self->mode} | ||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | ? ' for ' . $mode_msg{$self->mode} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | : ''; | ||||||||||||||||||||||||||||||||
| 118 | 1 | return qq{Can't open file$name$direction:\n$!}; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | #=============================================================================== | ||||||||||||||||||||||||||||||||
| 122 | sub copy { | ||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | my ($self, $new) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
copy: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | File::Copy::copy($self->name, $new) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | or die "failed to copy $self to $new: $!"; | ||||||||||||||||||||||||||||||||
| 127 | 1 | $self->file($new) | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | sub close { | ||||||||||||||||||||||||||||||||
| 131 | 126 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 132 | 126 | ▶ | return unless $self->is_open; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | 120 | $self->is_open(0); | |||||||||||||||||||||||||||||||
| 134 | 120 | my $io_handle = $self->io_handle; | |||||||||||||||||||||||||||||||
| 135 | 120 | $self->unlock; | |||||||||||||||||||||||||||||||
| 136 | 120 | $self->io_handle(undef); | |||||||||||||||||||||||||||||||
| 137 | 120 | $self->mode(undef); | |||||||||||||||||||||||||||||||
| 138 | 120 | ▶ | if (my $tied_file = $self->tied_file) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | 3 | ▶ | if (ref($tied_file) eq 'ARRAY') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 140 | 1 | untie @$tied_file; | |||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||
| 142 | else { | ||||||||||||||||||||||||||||||||
| 143 | 2 | untie %$tied_file; | |||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||
| 145 | 3 | $self->tied_file(undef); | |||||||||||||||||||||||||||||||
| 146 | 3 | return 1; | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | 117 | ▶ | $io_handle->close(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 149 | if defined $io_handle; | ||||||||||||||||||||||||||||||||
| 150 | 117 | return $self; | |||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | sub empty { | ||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
empty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 155 | 1 | -z $self->pathname; | |||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | sub filepath { | ||||||||||||||||||||||||||||||||
| 159 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
filepath: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 160 | 1 | my ($volume, $path) = $self->splitpath; | |||||||||||||||||||||||||||||||
| 161 | 1 | return File::Spec->catpath($volume, $path, ''); | |||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | sub getline_backwards { | ||||||||||||||||||||||||||||||||
| 165 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
getline_backwards: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 166 | 8 | $self->assert_open_backwards; | |||||||||||||||||||||||||||||||
| 167 | 8 | return $self->io_handle->readline; | |||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | sub getlines_backwards { | ||||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
getlines_backwards: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 172 | 1 | my @lines; | |||||||||||||||||||||||||||||||
| 173 | 1 | ▶ | while (defined (my $line = $self->getline_backwards)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | 3 | push @lines, $line; | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | 1 | return @lines; | |||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | sub head { | ||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
head: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | my $lines = shift || 10; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 10
MC/DC100%1/1
shift() || 10
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 182 | 2 | my @return; | |||||||||||||||||||||||||||||||
| 183 | 2 | $self->close; | |||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | LINES: | ||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | while ($lines--) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 187 | 15 | ▶ | if (defined (my $l = $self->getline)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | 15 | push @return, $l; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | else { | ||||||||||||||||||||||||||||||||
| 191 | 0 | last LINES; | |||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 2 | $self->close; | |||||||||||||||||||||||||||||||
| 196 | 2 | ▶ | return wantarray ? @return : join '', @return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | sub tail { | ||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
tail: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my $lines = shift || 10; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 10
MC/DC0%0/1
shift() || 10
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 202 | 0 | my @return; | |||||||||||||||||||||||||||||||
| 203 | 0 | $self->close; | |||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | while ($lines--) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | unshift @return, ($self->getline_backwards or last); | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->getline_backwards || (last)
MC/DC0%0/1
$self->getline_backwards || (last)
$self->getline_backwards
Truth table0%0/2
A
A= $self->getline_backwards
| |||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||
| 207 | 0 | $self->close; | |||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | return wantarray ? @return : join '', @return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||
| 211 | sub touch { | ||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
touch: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 213 | 2 | ▶ | return $self->SUPER::touch(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 214 | if -e $self->pathname; | ||||||||||||||||||||||||||||||||
| 215 | 1 | ▶ | return $self if $self->is_open; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 216 | 1 | my $mode = $self->mode; | |||||||||||||||||||||||||||||||
| 217 | 1 | $self->mode('>>')->open->close; | |||||||||||||||||||||||||||||||
| 218 | 1 | $self->mode($mode); | |||||||||||||||||||||||||||||||
| 219 | 1 | return $self; | |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | sub unlink { | ||||||||||||||||||||||||||||||||
| 223 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
unlink: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 224 | 3 | unlink $self->pathname; | |||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||
| 227 | #=============================================================================== | ||||||||||||||||||||||||||||||||
| 228 | sub _overload_table { | ||||||||||||||||||||||||||||||||
| 229 | 63 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_overload_table: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 230 | ( | ||||||||||||||||||||||||||||||||
| 231 | 63 | $self->SUPER::_overload_table(@_), | |||||||||||||||||||||||||||||||
| 232 | 'file > file' => '_overload_file_to_file', | ||||||||||||||||||||||||||||||||
| 233 | 'file < file' => '_overload_file_from_file', | ||||||||||||||||||||||||||||||||
| 234 | '${} file' => '_overload_file_as_scalar', | ||||||||||||||||||||||||||||||||
| 235 | '@{} file' => '_overload_file_as_array', | ||||||||||||||||||||||||||||||||
| 236 | '%{} file' => '_overload_file_as_dbm', | ||||||||||||||||||||||||||||||||
| 237 | ) | ||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||
| 240 | sub _overload_file_to_file { | ||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | require File::Copy; | ||||||||||||||||||||||||||||||
|
Subroutine
_overload_file_to_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 242 | 2 | File::Copy::copy($_[1]->pathname, $_[2]->pathname); | |||||||||||||||||||||||||||||||
| 243 | 2 | $_[2]; | |||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||
| 246 | sub _overload_file_from_file { | ||||||||||||||||||||||||||||||||
| 247 | 2 | ▶ | require File::Copy; | ||||||||||||||||||||||||||||||
|
Subroutine
_overload_file_from_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 248 | 2 | File::Copy::copy($_[2]->pathname, $_[1]->pathname); | |||||||||||||||||||||||||||||||
| 249 | 2 | $_[1]; | |||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||
| 252 | sub _overload_file_as_array { | ||||||||||||||||||||||||||||||||
| 253 | 6 | ▶ | $_[1]->assert_tied_file; | ||||||||||||||||||||||||||||||
|
Subroutine
_overload_file_as_array: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||
| 256 | sub _overload_file_as_dbm { | ||||||||||||||||||||||||||||||||
| 257 | 5 | ▶ | $_[1]->dbm | ||||||||||||||||||||||||||||||
|
Subroutine
_overload_file_as_dbm: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 258 | unless $_[1]->isa('IO::All::DBM'); | ||||||||||||||||||||||||||||||||
| 259 | 5 | $_[1]->_assert_open; | |||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||
| 262 | sub _overload_file_as_scalar { | ||||||||||||||||||||||||||||||||
| 263 | 10 | ▶ | my $scalar = $_[1]->scalar; | ||||||||||||||||||||||||||||||
|
Subroutine
_overload_file_as_scalar: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 264 | 10 | return \$scalar; | |||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||
| 267 | 59 | 1; | |||||||||||||||||||||||||||||||