Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Answer: How do I get a reference to a builtin function?

by igoryonya (Scribe)
on Dec 08, 2009 at 10:07 UTC ( #811702=categorized answer: print w/replies, xml ) Need Help??

Q&A > references > How do I get a reference to a builtin function? - Answer contributed by igoryonya

I'd say:
my %op = ( 'toupper'=>sub{uc(@_)}, ... );
instead of shift

Replies are listed 'Best First'.
Re: Answer: How do I get a reference to a builtin function?
by moritz (Cardinal) on Dec 08, 2009 at 11:25 UTC
    Please test your code before you offer it as a solution:
    $ perl -wE 'my $t = sub { uc(@_)}; say $t->("foo")' 1

    uc has a prototype which forces scalar context, so uc(@_) evaluates to the number of elements in @ (upper-cased).

    Perl 6 - links to (nearly) everything that is Perl 6.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Corion]: Also, I think the OPs problem is on their intranet and not on the internet (also, they should likely use WWW::Mechanize instead, which knows about cookie)
[1nickt]: yes, could be.
[1nickt]: I don;t see the link , definitely, after reloading the node
[1nickt]: Is it possible to disable it?
[Discipulus]: if you mean [download] after the code it is there 1nickt
[1nickt]: yes, Corion sees it too, and I see it when not logged in.
[Corion]: I think you can disable download links in your settings?
[1nickt]: Looking in settings to see if I disabled it in my profile ...
[1nickt]: There is "Don;t show embedded d/l links" in Display settings. It is unchecked.
[1nickt]: Oh, there is a minimum lines setting!

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-05-23 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?