| 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
| |||||||||||
| 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
| |||||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 3 | q[select $old_fh]; | |||||||||
| 31 | |||||||||||
| 32 | __END__ | ||||||||||