| 1 | package UNIVERSAL::which; | ||||||||||
| 2 | 6 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 6 | our $VERSION = sprintf "%d.%02d", q$Revision: 0.6 $ =~ /(\d+)/g; | |||||||||
| 6 | |||||||||||
| 7 | 15 | ▶ | sub UNIVERSAL::which { | ||||||||
|
Subroutine
which: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||
| 8 | 15 | my ( $self, $method ) = @_; | |||||||||
| 9 | 15 | my $coderef = $self->can($method); | |||||||||
| 10 | 15 | ▶ | unless ($coderef) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | 3 | $method = 'AUTOLOAD'; | |||||||||
| 12 | 3 | $coderef = $self->can($method); | |||||||||
| 13 | } | ||||||||||
| 14 | 15 | ▶ | return unless UNIVERSAL::isa($coderef, 'CODE'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 14 | require B; | |||||||||
| 16 | 14 | my $b = B::svref_2object($coderef); | |||||||||
| 17 | 14 | my $cvflags = $b->CvFLAGS; | |||||||||
| 18 | 14 | my $pkg = $b->GV->STASH->NAME; | |||||||||
| 19 | 14 | my $fq = $pkg . '::' . $method; | |||||||||
| 20 | 14 | ▶ | if (! defined(&{$fq}) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 6 | $method = $b->GV->NAME; | |||||||||
| 22 | 6 | $fq = $pkg . '::' . $method; | |||||||||
| 23 | 6 | ▶ | $fq = undef unless defined(&{$fq}); # double-check | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | } | ||||||||||
| 25 | 14 | ▶ | return wantarray ? ( $pkg, $method, $cvflags ) : $fq; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 6 | 1; | |||||||||
| 29 | __END__ | ||||||||||