tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:
Where is this documented?# http://prometheus.frii.com/%7Egnat/yapc/2000-stages/slide47.html # (Nathan Torkington on Opaque Objects) sub new { my $value = 0; bless sub { local $_ = shift; /get/ and return $value or /set/ and $value = shift or die "Unknown method: $_"; }, shift; } sub get { +shift->("get", @_) } sub set { +shift->("set", @_) }
This idiom is also mentioned in Re: Perl parser tortured (was: Perl Idioms Explained) but I still don't understand it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What is the + in +shift doing here?
by gellyfish (Monsignor) on Feb 23, 2005 at 17:18 UTC | |
|
Re: What is the + in +shift doing here?
by Anonymous Monk on Feb 23, 2005 at 17:18 UTC | |
|
Re: What is the + in +shift doing here?
by davido (Cardinal) on Feb 23, 2005 at 17:22 UTC | |
by Anonymous Monk on Feb 24, 2005 at 10:54 UTC | |
|
Re: What is the + in +shift doing here?
by Roy Johnson (Monsignor) on Feb 23, 2005 at 17:48 UTC | |
by Anonymous Monk on Feb 24, 2005 at 10:58 UTC | |
by Roy Johnson (Monsignor) on Feb 24, 2005 at 15:26 UTC | |
by Anonymous Monk on Feb 24, 2005 at 16:35 UTC | |
by Roy Johnson (Monsignor) on Feb 24, 2005 at 16:43 UTC | |
|