Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Fun with Closures

by Schemer (Scribe)
on Mar 25, 2003 at 02:13 UTC ( [id://245595]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # an object is simply a closure with a hash of closures
    sub make_object {
    ...
                $msg{$m}->(@_) : print "unknown message\n";
        }
    }
    
  2. or download this
    # build an object
    my $object = make_object();
    ...
    &$object("get-self")->("add-msg", "test", sub {print "test ok!\n"});
    &$object("test"); # ==> display "test ok!"
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://245595]
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-19 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found