in reply to Re^2: Dynamic Package Name & Subroutine Call
in thread Dynamic Package Name & Subroutine Call
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.
$full_pkg->$method_name(...);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Dynamic Package Name & Subroutine Call
by Anonymous Monk on Dec 17, 2012 at 08:51 UTC | |
by ikegami (Patriarch) on Dec 17, 2012 at 13:06 UTC | |
by Anonymous Monk on Dec 17, 2012 at 13:10 UTC | |
by ikegami (Patriarch) on Dec 19, 2012 at 12:46 UTC | |
by Anonymous Monk on Dec 21, 2012 at 03:42 UTC |