Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: referring to packages indirectly

by kwaping (Priest)
on Oct 11, 2006 at 15:26 UTC ( [id://577621]=note: print w/replies, xml ) Need Help??


in reply to referring to packages indirectly

This minor modification worked for me:
eval { no strict "refs"; require "$fqn_file"; local $SIG{'__DIE__'}; ###$ref = $foo->can('f_preferred') ? \&{$foo . "::f_preferred" +} : undef; $ref = $foo->can('f_preferred'); };
Read up on UNIVERSAL for more info.

Update: I too needed to read up on UNIVERSAL, as can does exactly what the OP was looking for without my redundant ternary operator.

---
It's all fine and dandy until someone has to look at the code.

Replies are listed 'Best First'.
Re^2: referring to packages indirectly
by chromatic (Archbishop) on Oct 11, 2006 at 23:39 UTC

    Be careful with that, as can() searches all parent classes for the subroutine. That might not be what you want.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-18 06:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found