Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Perl Monk, Perl Meditation
 
PerlMonks  

friedo's scratchpad

by friedo (Prior)
on Jul 07, 2004 at 01:43 UTC ( #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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (20)
As of 2014-04-17 16:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (453 votes), past polls