in reply to Re^2: trouble with evaluate
in thread trouble with evaluate

can be queried to get values of any of 50-100 different values that it holds

I think what you want is actually rather simple.  The classic way to store instance data is in the hash that makes up the object ($self here). In other words, as the "variable names" are just keys in the hash (i.e. strings), there's no need for eval or anything like this.  Your envisaged generic accessor (get_var) could just do a simple hash lookup:

ackage parser; sub new { my $self = bless {}, $_[0]; $self->parse(); return $self; } sub parse{ my $self = shift; $self->{var1} = 'foo'; $self->{var2} = 'bar'; #... } sub get_var{ my ($self, $var_name) = @_; return $self->{$var_name}; } package main; my $p = parser->new(); print $p->get_var('var1'); # -> foo print $p->get_var('var2'); # -> bar

(note that ->parse() doesn't necessarily have to be called from the constructor)