in reply to issues with eval (get a variable's value)

Also see Coping With Scoping

  • Comment on Re: issues with eval (get a variable's value)

Replies are listed 'Best First'.
Re^2: issues with eval (get a variable's value)
by squale (Initiate) on Sep 12, 2007 at 14:38 UTC
    Thanks for all your answers, but it seems i am missing something.
    if i write
    my $t; sub show { print eval "\$$_" for @_; } sub init { $t = 'test'; show(qw( t )); } => nothing
    but if i write
    my $t; sub show { print $t; print eval "\$$_" for @_; } sub init { $t = 'test'; show(qw( t )); } => testtest
    So it seems eval can not find $t in the right scope but if i use $t in a usual way before calling eval, it can find it...