line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ex::override; |
2
|
|
|
|
|
|
|
# $Id: override.pm,v 1.1 2003/03/14 14:58:53 cwest Exp $ |
3
|
2
|
|
|
2
|
|
1025
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
40
|
|
5
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
223
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
9
|
use vars qw[$VERSION @ISA]; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
398
|
|
8
|
|
|
|
|
|
|
$VERSION = (qw$Revision: 1.1 $)[1]; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw[ex::override::functions]; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
6
|
|
|
6
|
|
48
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
6
|
100
|
|
|
|
179
|
return unless @_; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
12
|
my %functions = @_; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
8
|
my $caller = caller(0); |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
10
|
foreach ( keys %functions ) { |
22
|
5
|
100
|
|
|
|
14
|
if ( s/^GLOBAL_// ) { |
23
|
1
|
|
|
|
|
1
|
$caller = 'CORE::GLOBAL'; |
24
|
1
|
|
|
|
|
2
|
$functions{$_} = $functions{'GLOBAL_'.$_}; |
25
|
|
|
|
|
|
|
} |
26
|
5
|
50
|
|
|
|
52
|
unless ( prototype "CORE::$_" ) { |
27
|
0
|
|
|
|
|
0
|
croak "$_ cannot be overriden because it doesn't have a prototype"; |
28
|
|
|
|
|
|
|
} |
29
|
2
|
|
|
2
|
|
9
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
375
|
|
30
|
5
|
|
|
|
|
8
|
*{'ex::override::functions::'.$_} = \&{$functions{$_}}; |
|
5
|
|
|
|
|
31
|
|
|
5
|
|
|
|
|
8
|
|
31
|
5
|
|
|
|
|
8
|
*{$caller.'::'.$_} = \&{'ex::override::functions::'.$_}; |
|
5
|
|
|
|
|
254
|
|
|
5
|
|
|
|
|
11
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub unimport { |
36
|
4
|
|
|
4
|
|
18
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
4
|
100
|
|
|
|
16
|
my @remove = ( @_ ? @_ : keys %ex::override::functions:: ); |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
7
|
my $caller = caller(0); |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
6
|
foreach ( @remove ) { |
43
|
7
|
|
|
|
|
10
|
s/^GLOBAL_//; |
44
|
7
|
|
|
|
|
8
|
delete $CORE::GLOBAL{$_}; |
45
|
7
|
|
|
|
|
332
|
eval 'delete $'.$caller."::{$_}"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |