in reply to [untitled node, ID 216639]

Syntax for variable interpolation you're searching is simple:
${"$letter$number"};
but this will be a syntax error when use strict; in effect.
use strict; could be calmed down by using eval:
my $result = eval "\$$letter$number";

But most correct way to solve your problem is just use arrays or hashes.

Best wishes,
Courage, the Cowardly Dog

Replies are listed 'Best First'.
Re: Re: Variables in variable names
by tachyon (Chancellor) on Nov 30, 2002 at 14:40 UTC
    $letter = 'Oops'; $number = ";print 'You have been hacked!';"; my $result = eval "\$$letter$number";

    Eval (and symbolic references) are dangerous - that print could have been rf -rm /*. Just don't do it.... Typo intentional.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I am absolutely agree with you
      Besides, /perlfaq\d/ warns about huge sequrity holes in such situations.

      But I tried to provide Samn with a syntax he was searching, and after that to advice a better and safer way to solve his task.

      Best wishes,
      Courage, the Cowardly Dog