Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Dec 212010

How can I find out my current package in Perl?


To find the current package in your Perl script, you can try something like the following:

package Foo;

my $current_package = __PACKAGE__;
print "I am in package $current_package\n";


When executed:

# perl

I am in package Foo

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>