Please try below code
my $cmd = '$var1 = 5'; eval "$cmd"; print $var1; [download]
In reply to Re^2: Executing a string as a Perl command by johnpeterdinesh in thread Executing a string as a Perl command by tel2