On Wed, Sep 01, 2004 at 08:11:22AM -0700, Palit, Nilanjan wrote: > I want to print the values of a bunch of variables so I thought I'll > take a shortcut and do this: > > foreach (qw(var1 var2 var3 var4)) > { > print "$_ -> ${$_}\n"; > } > > I had thought that interpolating the variable name ("${$_}") would cause > Perl to interpret the correct variable name & print its value, but it > printed nothing. > > Is my syntax wrong or is this not possible at all? I checked Mr. Camel, > but did not find anything there on this specifically.
Symbolic references only work for package variables. I suspect that you have declared the variables in question with my(), making them lexical variables, which means they're not in the symbol table and can't be accessed with symbolic references. The PadWalker module can be used to access lexical variables. Ronald P.S. The address for this list is [EMAIL PROTECTED] Sending to just that address is sufficient; you do not need to send to [EMAIL PROTECTED] or [EMAIL PROTECTED] _______________________________________________ Boston-pm mailing list [EMAIL PROTECTED] http://mail.pm.org/mailman/listinfo/boston-pm