in reply to How to identify calling class whilst in inherited method
I ignore "main" because this is always a startup script.sub GetCaller { my $self = shift; my $i = 0; my $result; while (1) { my ($package, $filename, $line, $subroutine) = caller($i++); if (defined($package) && ($package ne "main")) { $result = $subroutine; } else { last; } }; return $result; }
|
|---|