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

friedo's scratchpad

by friedo (Prior)
on Jul 07, 2004 at 01:43 UTC ( [id://372242]=scratchpad: print w/replies, xml ) Need Help??

friedo's scratchpad
package Friedo::Test; use strict; use warnings; use base 'Friedo'; our $VERSION = '0.01'; { # set up some defaults my %CLASSDATA = ( foo => 1, bar => 2, baz => 3 ); # install some generic class/instance accessors no strict 'refs'; for my $key(keys %CLASSDATA) { *$key = sub { my $i = shift; if(ref $i) { $CLASSDATA{$i}{$key} = shift if $_[0]; return $CLASSDATA{$i}{$key} or $CLASSDATA{$key}; } else { $CLASSDATA{$key} = shift if $_[0]; return $CLASSDATA{$key}; } }; } use strict 'refs'; } # constructor sub new { my $invocant = shift; my %args = @_; my $self = $invocant->SUPER::new; bless $self, ref($invocant) || $invocant; return $self->_init(\%args); } # initialize new object sub _init { my $self = shift; my $args = shift; # store our instance data foreach my $key(keys %{ $args }) { my $tmp = $key; $tmp =~ s/^-//; if($self->can($tmp)) { $self->$tmp($args->{$key}); } } return $self; }
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found