Thanks for the responses. I did use "my" to declare the variables - removing that allowed me to reference the variables correctly.
-Nilanjan PS: Apologies for the multiple posts. I post rather infrequently and the time before this, I had had a lot of problems (which I found out later was due to the boston-pm server), so I had been unsure of the address. Will limit it to a single address next time. -----Original Message----- From: Ronald J Kimball [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 01, 2004 11:28 AM To: Palit, Nilanjan Cc: [EMAIL PROTECTED] Subject: Re: [Boston.pm] RE: Interpolating variables 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

