The stupid question is the question not asked | |
PerlMonks |
Executing a string as a Perl commandby tel2 (Pilgrim) |
on May 10, 2011 at 01:25 UTC ( [id://903872]=perlquestion: print w/replies, xml ) | Need Help?? |
tel2 has asked for the wisdom of the Perl Monks concerning the following question: Hi Monks, What is a simple way to execute a string as a Perl command, in a Perl script? For example, let's say I have a scalar assignment like this: $cmd = '$var1 = 5;';If I want to execute $cmd, ending up with $var1 containing 5, what's an easy way to do it, (without parsing the string, picking out the variable & value, and making the assignment with an indirect reference). I've looked at 'eval', and other posts here, but can't find anything appropriate yet. Thanks.
Back to
Seekers of Perl Wisdom
|
|