<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">No, it's not the map call. It's definitely the quoting within the braces around the variable name that seems to be causing this behavior. I'll research it a bit more in my Perl books (maybe even check out perlmonks.org) and see if I can find an explaination besides my "it's that way because it was designed that way" one.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>The following code will produce the same problems:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>#!/usr/bin/perl</DIV><DIV>use strict;</DIV><DIV>use warnings;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>our $foo = "global foo";</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>{</DIV><DIV> my $foo = "local foo";</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> print '${foo} = ' . ${foo} . "\n"; # Produces "local foo"</DIV><DIV> print '$("foo"} = ' . ${"foo"} . "\n"; # Produces "global foo"</DIV><DIV>}</DIV><DIV><BR><DIV><DIV>On Feb 8, 2006, at 9:51 PM, Tim Wilson wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite">My guess is because of the map call using a block. Since you have another block, you're referencing the global vars instead of the local vars, because the local vars were in a different block. Just a guess.<BR><BR><DIV><SPAN class="gmail_quote"> On 2/8/06, <B class="gmail_sendername">Renegade Muskrat</B> <<A href="mailto:dramaley@spatulacity.cx" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">dramaley@spatulacity.cx</A>> wrote:</SPAN> <BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> I have a question regarding Perl. I am having trouble figuring out the<BR>variable scoping in a script. I've reduced the problem to as simple of<BR>a code snippet as i can in order to demonstrate it. In the script below<BR> <BR>i believe $test1 and $test2 should be the same. But they are not. Any<BR>ideas why not? And how to make both of them display the local<BR>variables? Or a better place to ask Perl questions?<BR><BR><BR>The script:<BR> <BR> <BR>#!/usr/bin/perl<BR>use strict;<BR>use warnings;<BR><BR>our $foo = "global foo";<BR><BR>{<BR> my $foo = "local foo";<BR> my $bar = "local bar";<BR><BR> no strict 'refs';<BR> my $test1 = join("\n", map { "$_ => ${$_}"; } qw(foo bar)); <BR> my $test2 = join("\n", "foo => $foo", "bar => $bar");<BR><BR> print "$test1\n----------\n$test2\n";<BR>}<BR><BR><BR>The output:<BR><BR><BR>Use of uninitialized value in concatenation (.) or string at <BR>./scratch line 12.<BR>foo => global foo<BR>bar =><BR>----------<BR>foo => local foo<BR>bar => local bar<BR><BR>_______________________________________________<BR>Cialug mailing list<BR><A href="mailto:Cialug@cialug.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> Cialug@cialug.org</A><BR><A href="http://cialug.org/mailman/listinfo/cialug" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://cialug.org/mailman/listinfo/cialug</A><BR></BLOCKQUOTE></DIV><BR> <BR clear="all"><BR>-- <BR>Tim <DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Cialug mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:Cialug@cialug.org">Cialug@cialug.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug</A></DIV> </BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>