in reply to Re: Re: Variable expansion
in thread Variable expansion

If you do have the unfortunate case of having the string not being interpolated then you could use the string version of eval() to get the desired result.
my $hr = { foo => { bar => '/dev/null' } }; my $cmd_literal = 'ls $hr->{foo}->{bar}'; my $cmd = eval qq(return "$cmd_literal";); print `$cmd`; __output__ /dev/null
But the best option would be to have $cmd be interpolated rather than resorting to eval().
HTH

broquaint

Replies are listed 'Best First'.
Re: Re: Re: Re: Variable expansion
by stephenpry (Initiate) on Apr 17, 2002 at 14:34 UTC
    Brilliant ! That works, thankyou.. I've struggled all morning with this (in Scotland ..)