| 1 | package Net::FSP::Handle; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use base 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | our $VERSION = $Net::FSP::VERSION; | |||||||||
| 7 | 2 | our @EXPORT_OK = qw/do_or_fail/; | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use Errno qw/EIO/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 2 | require Net::FSP::Handle::Read; | |||||||||
| 13 | 2 | require Net::FSP::Handle::Write; | |||||||||
| 14 | |||||||||||
| 15 | 2 | my %class_for = ( | |||||||||
| 16 | '<' => 'Net::FSP::Handle::Read', | ||||||||||
| 17 | '>' => 'Net::FSP::Handle::Write', | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub do_or_fail(&) { ##no critic prototype | ||||||||
|
Subroutine
do_or_fail: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 21 | 0 | my $action = shift; | |||||||||
| 22 | 0 | local $@; | |||||||||
| 23 | 0 | my $ret; | |||||||||
| 24 | 0 | eval { $ret = $action->(); }; | |||||||||
| 25 | 0 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | $! = EIO; | |||||||||
| 27 | 0 | return; | |||||||||
| 28 | } | ||||||||||
| 29 | 0 | return $ret; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | sub TIEHANDLE { | ||||||||
|
Subroutine
TIEHANDLE: not called CC=2 SCAR=17.9
| |||||||||||
| 33 | 0 | my (undef, $fsp, $filename, $mode) = @_; | |||||||||
| 34 | 0 | ▶ | my $class = $class_for{$mode} or croak "Invalid or unsuppored mode specified\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | my $self = bless { fsp => $fsp }, $class; | |||||||||
| 36 | 0 | $self->OPEN($mode, $filename); | |||||||||
| 37 | 0 | return $self; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub CLOSE { | ||||||||
|
Subroutine
CLOSE: not called CC=3 SCAR=24.8
| |||||||||||
| 41 | 0 | my $self = shift; | |||||||||
| 42 | 0 | for my $key (keys %{$self}) { | |||||||||
| 43 | 0 | ▶ | delete $self->{$key} if $key ne 'fsp'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | } | ||||||||||
| 45 | 0 | return 1; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub DESTROY { | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||
| 49 | 0 | my $self = shift; | |||||||||
| 50 | 0 | $self->CLOSE; | |||||||||
| 51 | 0 | return; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 2 | 1; | |||||||||
| 55 | |||||||||||
| 56 | __END__ | ||||||||||