|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package UNIVERSAL::dump;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # version info  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $VERSION= '0.09';  | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # be as strict and verbose as possible  | 
| 
7
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
2147
 | 
 use strict;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
91
 | 
    | 
| 
8
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
16
 | 
 use warnings;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
239
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # presets  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my %preset= (  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
  blessed => 'Scalar::Util::blessed',  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
  dump    => 'Data::Dumper::Dumper',  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
  peek    => 'Devel::Peek::Dump',  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
  refaddr => 'Scalar::Util::refaddr',  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # installed handlers  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my %installed;  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # satisfy require  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #-------------------------------------------------------------------------------  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Perl specific subroutines  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #-------------------------------------------------------------------------------  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  IN: 1 class (ignored)  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #      2..N method => subroutine pairs  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub import {  | 
| 
33
 | 
21
 | 
 
 | 
 
 | 
  
21
  
 | 
 
 | 
3874
 | 
     my $class= shift;  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # make sure default is set  | 
| 
36
 | 
21
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
49
 | 
     unshift( @_,'dump' ) unless @_;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # allow for redefining subroutines  | 
| 
39
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
18
 | 
     no warnings 'redefine';  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
819
 | 
    | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # handle all simple specifications  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   METHOD:  | 
| 
43
 | 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
30
 | 
     foreach my $spec (@_) {  | 
| 
44
 | 
27
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
48
 | 
         if ( !ref($spec) ) {  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             die qq{Don't know how to install method "UNIVERSAL::$spec"\n}  | 
| 
46
 | 
10
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
35
 | 
               unless my $sub= $preset{$spec};  | 
| 
47
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
33
 | 
             $class->import( { $spec => $sub } );  | 
| 
48
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
42
 | 
             next METHOD;  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         # all methods  | 
| 
52
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22
 | 
         foreach my $method ( keys %{$spec} ) {  | 
| 
 
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
    | 
| 
53
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
             my $sub= $spec->{$method};  | 
| 
54
 | 
17
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
29
 | 
             $sub= $preset{$sub} if $preset{$sub};  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # already installed  | 
| 
57
 | 
17
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
30
 | 
             if ( my $installed= $installed{$method} ) {  | 
| 
58
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
22
 | 
                 die qq{Cannot install "UNIVERSAL::$method" with "$sub":}  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     . qq{ already installed with "$installed"\n}  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                   if $sub ne $installed;  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # mark method as installed  | 
| 
64
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
             ( my $module= $sub ) =~ s#::[^:]+$##;  | 
| 
65
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
             $module =~ s#::#/#;  | 
| 
66
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
             $module .= ".pm";  | 
| 
67
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22
 | 
             $installed{$method}= $sub;  | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # install the method in the indicated namespace  | 
| 
70
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
24
 | 
             no strict 'refs';  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
558
 | 
    | 
| 
71
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
81
 | 
             *{"UNIVERSAL::$method"}= sub {  | 
| 
72
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
 
 | 
15865
 | 
                 my $self = shift;  | 
| 
73
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
                 eval { require $module };  | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
332
 | 
    | 
| 
74
 | 
8
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
53
 | 
                 return $sub->( @_ ? @_ : $self ) if defined wantarray;  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
75
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
                 print STDERR $sub->( @_ ? @_ : $self );  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             } #UNIVERSAL::$method  | 
| 
77
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
48
 | 
         }  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 } #import  | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #---------------------------------------------------------------------------  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |