can should be used for methods and only for methods, so that should be
my $full_pkg = "Test::".$pkg; my $hello = $full_pkg->can('hello'); $full_pkg->$hello(...); # Or: $hello->($full_pkg, ...);
which simplifies to:
my $full_pkg = "Test::".$pkg; $full_pkg->hello(...);
You don't even need can if the method name is variable.
|Replies are listed 'Best First'.|
Re^4: Dynamic Package Name & Subroutine Call
by Anonymous Monk on Dec 17, 2012 at 08:51 UTC