in reply to How do I get to this 'simple' helper?

Simple fix you escape the $ for $t and $_ using \ before dollar sign

untested
my @vars = ('instance1','instance2',..); foreach (@vars) { eval "sub $_ { my \$self = shift; if (@_) { \$self->{$_} = shift; } return \$self->{$_}; }"; }

Replies are listed 'Best First'.
Re^2: How do I get to this 'simple' helper?
by AnomalousMonk (Archbishop) on Sep 03, 2010 at 01:49 UTC
    if (@_) { \$self->{$_} = shift; }

    Arrays get interpolated too, so I think the code above – and likewise in OPed code – should be (note  \@_ vice  @_):

    if (\@_) { \$self->{$_} = shift; }