blib/lib/Lexical/select.pm

filter: Statementstmt 100% 22 / 22 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 97.0% 33 / 34 CC 3 SCAR 4.1
CC
3
Cov
96%
restore
2.0
DESTROY
2.0
BEGIN
1.0
CRAP 1.5
↑ Summary
1 package Lexical::select;
2 3 $Lexical::select::VERSION = '0.10';
3 #ABSTRACT: provides a lexically scoped currently selected filehandle
4  
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Symbol 'qualify_to_ref';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our @ISA = qw[Exporter];
10 3 our @EXPORT = qw[lselect];
11  
12 2 ▶sub lselect {
Subroutine lselect: called CC=1 SCAR=0.0
Pod documented
13 2 my $handle = qualify_to_ref(shift, caller);
14 2 my $old_fh = CORE::select $handle;
15 2 return bless { old_fh => $old_fh }, __PACKAGE__;
16 }
17  
18 2 ▶sub restore {
Subroutine restore: called CC=2 SCAR=7.0
Pod documented
19 2 my $self = shift;
20 2 ▶ return if $self->{_restored};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_restored"} 0 2 2
21 2 CORE::select delete $self->{old_fh};
22 2 return $self->{_restored} = 1;
23 }
24  
25 2 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=6.9
26 2 my $self = shift;
27 2 ▶ $self->restore unless $self->{_restored};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_restored"} 1 1 2
28 }
29  
30 3 q[select $old_fh];
31  
32 __END__
↑ Summary