Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 romping around the Monastery: (7)
As of 2015-07-04 08:06 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 (58 votes), past polls