<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:tahoma, new york, times, serif;font-size:12pt"><DIV></DIV>
<DIV>apologies - i'll abstain from further coding examples until i am able to compile them. i have no computer at present, and am attempting to&nbsp;get it from memory - kind of a&nbsp;pseudo coder. i did read up a little on the break, and i think my opinion about this was to not use global variables, but if they couldn't be avoided, use package variables instead. </DIV>
<DIV>&nbsp;</DIV>
<DIV>again, my apologies to the list.<BR>&nbsp;</DIV>---<BR>Mark Mertel<BR>206.441.4663<BR>mark.mertel@yahoo.com<BR>http://www.linkedin.com/in/markmertel<BR>http://www.seattlejobs.com/13147468
<DIV><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: tahoma, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: arial, helvetica, sans-serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Ronald J Kimball &lt;rjk-spug@tamias.net&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> spug-list@pm.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Tuesday, March 24, 2009 1:37:33 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: SPUG: Confusing behaivior with exported variables<BR></FONT><BR>On Tue, Mar 24, 2009 at 12:25:39PM -0700, Mark Mertel wrote:<BR>&gt;<BR>&gt; It does work:<BR>&gt;<BR>&gt; package Foo;<BR>&gt; my $bar = "foo bar\n";<BR>&gt; 1;<BR>&gt; ...<BR>&gt;<BR>&gt; use Foo;<BR>&gt; use strict;<BR>&gt;<BR>&gt; print $Foo::bar; # prints 'foo bar'<BR>&gt;<BR>&gt; print $bar; # should throw an error<BR><BR>Did you actually execute this code?&nbsp; It /does not/ do what you say it does.<BR><BR>It would be a very good idea for you to take the time to understand how<BR>my()/our() and lexical/package variables actually work before you spread<BR>more
 misinformation on this subject.<BR><BR>Variables declared with my() are lexically scoped.&nbsp; They are not stored in<BR>the symbol table.&nbsp; They are accessible only from within that lexical scope.<BR><BR>Variables declared with our() are package variables.&nbsp; They are stored in<BR>the symbol table.&nbsp; They are accessible globally, but may need to be fully<BR>qualified.<BR><BR>package Foo;<BR>use strict;<BR><BR>{<BR>&nbsp; my $foo = 'foo';&nbsp; # sets lexical $foo<BR><BR>&nbsp; print "$foo\n";&nbsp; &nbsp; # prints 'foo'<BR>}<BR><BR>#print "$foo\n";&nbsp; &nbsp; # error under use strict, prints undef otherwise<BR><BR>{<BR>&nbsp; my $foo;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # a different lexical $foo<BR>&nbsp; print "$foo\n";&nbsp; &nbsp; # prints undef<BR>}<BR><BR>{<BR>&nbsp; our $bar = 'bar';&nbsp; # sets $Foo::bar<BR>&nbsp; print "$bar\n";&nbsp; &nbsp; # prints 'bar'<BR>}<BR><BR>#print "$bar\n";&nbsp; &nbsp; # error under use strict, prints
 'bar' otherwise<BR>print "$Foo::bar\n"; # prints 'bar'<BR><BR>{<BR>&nbsp; our $bar;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # same $Foo::bar<BR>&nbsp; print "$bar\n";&nbsp; &nbsp; # prints 'bar'<BR>}<BR><BR>Ronald<BR>_____________________________________________________________<BR>Seattle Perl Users Group Mailing List<BR>&nbsp; &nbsp; POST TO: <A href="mailto:spug-list@pm.org" ymailto="mailto:spug-list@pm.org">spug-list@pm.org</A><BR>SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list<BR>&nbsp; &nbsp; MEETINGS: 3rd Tuesdays<BR>&nbsp; &nbsp; WEB PAGE: http://seattleperl.org/<BR></DIV></DIV></div><br>

      </body></html>