in reply to abstraction - reusing OO module subs

sub _put_list ($@) { my $target = shift; my $self = shift ; push @{$self->{$target}}, @_; return scalar(@_); } eval "sub $_ { return _put_list($_ => \@_);}" for qw{column table};
Note: Not 100% tested code.

Hope this is of use.. Quite liked the dynamic evaluation but that is not neccessary.

sub column { return _put_list(column => @_); }
Hope this helps
UnderMine

Replies are listed 'Best First'.
Re: Re: abstraction - reusing OO module subs
by chromatic (Archbishop) on Nov 21, 2002 at 20:20 UTC

    Why AUTOLOAD exists:

    my %accessors = map { $_ => 1 } qw( table column ); sub AUTOLOAD { our $AUTOLOAD; $AUTOLOAD =~ s/::([^:]+)$//; return if $AUTOLOAD eq 'DESTROY'; if (exists $accessors{ $AUTOLOAD }) { no strict 'refs'; *{ $AUTOLOAD } = sub { my $self = shift; push @{ $self->{ $AUTOLOAD } }, @_; }; } }