ajwans has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to write some code which dynamically creates
'my' variables for evaluation by some user inputted perl
code. What I want is for perl to catch unregistered
variables which is why I want this to run under "use strict"
My problem is the dynamic creation of variables in the current scope, I'm trying the following.
my $bar = "fred";
eval "my \${$bar} = 'foo';";
print $fred;
I want this to print "foo", but I get errors, is there any way to do this?
My problem is the dynamic creation of variables in the current scope, I'm trying the following.
my $bar = "fred";
eval "my \${$bar} = 'foo';";
print $fred;
I want this to print "foo", but I get errors, is there any way to do this?
Back to
Seekers of Perl Wisdom