Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How do I construct a reference to a builtin function?

by jlawrenc (Scribe)
on Mar 21, 2001 at 05:08 UTC ( [id://65932]=note: print w/replies, xml ) Need Help??


in reply to How do I get a reference to a builtin function?

I do not know, personally, of any way to reference an builtin function. Although your idea has merit it may not be possible. Those more familiar with perlguts that I may have a different answer.

Now, if this specific magic is on your mind I will be of no help, but I offer this to try and satisfy your builtin reference cravings:

my(%hash) = ( "sub" => sub { uc $_[0] }, ); print $hash{"sub"}->("hello");
Since uc expects only a scalar we'll have to pick the first element of @_ for it. You may elect to use join as means to handle arrays in your call to "sub".

Your referencing strategy will differ slightly from function to function depending on what you want to accomplish.

Originally posted as a Categorized Answer.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-20 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found