http://www.perlmonks.org?node_id=492329


in reply to Re: Probably an easy one - store command in variable.
in thread Probably an easy one - store command in variable.

Just know that string eval can be costly (starts a new Perl interpreter) and potentially dangerous (you aren't using tainted user input to build this string are you?; run this with perl -T to find out for sure).

Are you running this under use strict;? If so, then you will have some problems with my @returnsting. Specifically, you will need to have @returnstring declared before your eval to use it later. That means when you eval "my @returnstring = ...", you will create lexical variable within the scope of the eval that will mask the @returnstring that you declared outside of the eval scope. To solve this, simply remove the my from the string that you build.

Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.