Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Dynamic Package Name & Subroutine Call

by ikegami (Pope)
on Dec 16, 2012 at 13:55 UTC ( #1009062=note: print w/ replies, xml ) Need Help??


in reply to Re: Dynamic Package Name & Subroutine Call
in thread Dynamic Package Name & Subroutine Call

The following works with strict on:

(\&{"Test::${pkg}::hello"})->($pkg);
The same, but more readable:
my $sub = \&{"Test::${pkg}::hello"}; $sub->($pkg);

Then again, explicitly using no strict 'refs'; might be better a good thing.

That said, it looks like you have a method call (to which you're passing the wrong package name). If so, you should be using

("Test::".$pkg)->hello(...);


Comment on Re^2: Dynamic Package Name & Subroutine Call
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009062]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2015-07-04 13:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls