in reply to Weird eval behavior...
This works fine for me:
@attribute_list = qw( foo bar baz ); $package="Zoikes"; for (@attribute_list) { my $sub = qq{package $package; sub get$_ { \$_[0]->get("$_") } }; eval $sub; warn "Problem with $_: $@\n" if $@; } { package Zoikes; sub get { print "Zoikes::get( $_[1] )\n" } } $z = bless { }, "Zoikes"; $z->getfoo; $z->getbar; $z->getbaz; exit 0;
Also consider checking out Class::MethodMaker to avoid reinventing too many wheels.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Weird eval behavior...
by dragonchild (Archbishop) on Oct 09, 2001 at 21:47 UTC | |
by Fletch (Bishop) on Oct 09, 2001 at 22:39 UTC |