Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Your favorite objects NOT of the hashref phylum

by ikegami (Patriarch)
on Mar 29, 2006 at 17:32 UTC ( [id://540015]=note: print w/replies, xml ) Need Help??


in reply to Your favorite objects NOT of the hashref phylum

I have two modules that use scalar objects:

package OnDestroy; BEGIN { our @EXPORT = qw( on_destroy ); require Exporter; *import = \&Exporter::import; } sub on_destroy(&) { my ($action) = @_; return bless(\$action); } sub cancel { my ($self) = @_; undef $$self; } sub DESTROY { my ($self) = @_; my $action = $$self; $action->() if $action; } 1;

and something I wrote in reponse to a question on PerlMonks:

package AutoExecute; BEGIN { our @EXPORT = qw( auto_execute ); require Exporter; *import = \&Exporter::import; } use overload '""' => \&stringify, '&{}' => \&code_ref, ; sub auto_execute(&) { my ($sub) = @_; return bless(\$sub); } sub new { my ($class, $sub) = @_; return bless(\$sub, $class); } sub stringify { my ($self) = @_; my $sub = $$self; return $sub->(); } sub code_ref { my ($self) = @_; my $sub = $$self; return $sub; } 1;

All my other objects are based on arrays.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found