Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Building an anonymous subroutine

by BorgCopyeditor (Friar)
on Aug 11, 2002 at 04:38 UTC ( #189267=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $encode = 'u'; # example, could be 'p', 'b', or 'u'
    $sub_ref = template($encode);
    
    ...
    ...time passes...
    
    $encoded_output = &$sub_ref;
    
  2. or download this
    sub template {
        my $e = shift;
        my $common = sub {...shared stuff...}
        if ($e eq 'b') { return sub {&$common; ...stuff...} }
        if ($e eq 'u') { return sub {&$common: ...other stuff...} }
    etc.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://189267]
Approved by djantzen
Front-paged by RhetTbull
help
Chatterbox?
[LanX]: hm just read an article on heise.de claiming that RPerl is 250 times faster. ... it's that even possible?
[marto]: under certain circumstances perhaps
[RonW]: as I understand it, RPerl "compiles" a subset of Perl to C, so I would expect the final executable to run a lot faster

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2017-05-22 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?