pelagic has asked for the wisdom of the Perl Monks concerning the following question:
Thanks for some inspiring hints!package Anything; sub new { my $class = shift; ## ... code here bless $self, $class; } sub prepare_create { ## .. do something } sub create { ## .. do something else } ## a.s.o. more methods here package Anything::List; sub new { my $class = shift; my @self = @_; bless \@self, $class; } sub add { my $self = shift; push @$self, @_; } sub list { my $self = shift; return @$self; } sub prepare_create { my $self = shift; foreach my $anything (@{$self}) { $anything->prepare_create(@_); } } sub create { my $self = shift; foreach my $anything (@{$self}) { $anything->create(@_); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: List Wrapper for Object Methods.
by Arunbear (Prior) on Dec 03, 2004 at 10:06 UTC | |
by pelagic (Priest) on Dec 03, 2004 at 11:25 UTC | |
by Arunbear (Prior) on Dec 03, 2004 at 12:01 UTC | |
|
Re: List Wrapper for Object Methods.
by diotalevi (Canon) on Dec 03, 2004 at 12:36 UTC | |
by pelagic (Priest) on Dec 03, 2004 at 15:45 UTC | |
|
Re: List Wrapper for Object Methods.
by dragonchild (Archbishop) on Dec 03, 2004 at 14:22 UTC | |
|
Re: List Wrapper for Object Methods.
by Prior Nacre V (Hermit) on Dec 03, 2004 at 13:38 UTC | |
|
Re: List Wrapper for Object Methods.
by tall_man (Parson) on Dec 03, 2004 at 16:02 UTC |