| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lexical::select; |
|
2
|
|
|
|
|
|
|
$Lexical::select::VERSION = '0.10'; |
|
3
|
|
|
|
|
|
|
#ABSTRACT: provides a lexically scoped currently selected filehandle |
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
46005
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
85
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
63
|
|
|
7
|
2
|
|
|
2
|
|
1943
|
use Symbol 'qualify_to_ref'; |
|
|
2
|
|
|
|
|
2352
|
|
|
|
2
|
|
|
|
|
486
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw[Exporter]; |
|
10
|
|
|
|
|
|
|
our @EXPORT = qw[lselect]; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub lselect { |
|
13
|
2
|
|
|
2
|
1
|
17156
|
my $handle = qualify_to_ref(shift, caller); |
|
14
|
2
|
|
|
|
|
32
|
my $old_fh = CORE::select $handle; |
|
15
|
2
|
|
|
|
|
17
|
return bless { old_fh => $old_fh }, __PACKAGE__; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub restore { |
|
19
|
2
|
|
|
2
|
1
|
1068
|
my $self = shift; |
|
20
|
2
|
50
|
|
|
|
19
|
return if $self->{_restored}; |
|
21
|
2
|
|
|
|
|
11
|
CORE::select delete $self->{old_fh}; |
|
22
|
2
|
|
|
|
|
11
|
return $self->{_restored} = 1; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub DESTROY { |
|
26
|
2
|
|
|
2
|
|
2200
|
my $self = shift; |
|
27
|
2
|
100
|
|
|
|
143
|
$self->restore unless $self->{_restored}; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
q[select $old_fh]; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |