in reply to How to display name of current package
Hello sylph001,
Your question is not entirely clear to me. So, although it seems likely that you’re looking for the __PACKAGE__ literal, as described by LanX and Discipulus, it’s just possible that you’re really looking for the functionality of Perl’s built-in caller function. The following snippet should make the difference clear:
#! perl use strict; use warnings; package Foo; sub f { my ($package, $filename, $line) = caller; printf "Function '%s::f()' called from package '%s'\n", __PACKAGE_ +_, $package; } package Bar; Foo::f();
Output:
22:24 >perl 1686_SoPW.pl Function 'Foo::f()' called from package 'Bar' 22:24 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|