Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

objects as closures

by Excalibor (Monk)
on Jul 07, 2003 at 15:07 UTC ( #271987=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
          die "Method '$_[0]' unknown to class Person";
       }
    }
    
  2. or download this
    # creating object
    my $john = Person;
    ...
    print "It's ", $john->('age')->(), " years-old already!!!\n";
    print $john->('address')->();
    __END__
    
  3. or download this
    I'm John and I am 23 years-old, but my birthday is in just 2 seconds
    [two seconds pass...]
    ...
    Uncaught exception from user code:
            Method 'address' unknown to class Person at closure.pl line 18
    +.
            main::__ANON__('address') called at closure.pl line 40
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2015-07-28 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls