This script from the Perl FAQ <http://www.perl.com/perl/faq/Q4.3.html> works as expected using 'my' in MacPerl 5.06: #!/usr/local/bin/perl $myvar = 10; $localvar = 10; print "Before the sub call - my: $myvar, local: $localvar\n"; &sub1(); print "After the sub call - my: $myvar, local: $localvar\n"; exit(0); sub sub1 { my $myvar; local $localvar; $myvar = 5; # Only in this block $localvar = 20; # Accessible to children print "Inside first sub call - my: $myvar, local: $localvar\n"; &sub2(); } sub sub2 { print "Inside second sub - my: $myvar, local: $localvar\n"; } and demonstrates how variables declared with 'my' are visible only in the block which names them. So my question is, in your example which is correct, MacPerl or Unix-Perl? When declared with my, should $a be visible in testmain.pl or should it only be visible in test.pl? Michael > I've run across a difference in behavior between MacPerl 5.06 and Perl > 5.001m on a Sun workstation. This difference has been annoying in > my attempt to get libwww-perl-5b6 to work on my Mac, so I wrote a > little test code to demonstrate the problem. Since I want to make > sure that it's not something on my Mac (Powerbook 165, 7.5.1) but is or > is not a problem with MacPerl, I'm sending this to the list rather than > to Matthias directly. > > The two files are short, so I'm not going to bother MIME'ing them > > test.pl: > > #!/usr/local/bin/perl > package test; > > #$a = "test"; > #my $a = "test"; > local $a = "test"; > > sub test {my $b = $a;return $b}; > 1; > > testmain.pl: > > #!/usr/local/bin/perl > > require "test.pl"; > > $a = test::test(); > print "$test::a, $a\n"; > > Running testmain with the declaration line in test changed gives > the following > > MacPerl 5.06 Sun Perl 5.001m $ > a: test, test test, test local $ > a: , , my $ > a: , , test > > > The latter is what's been the problem with lwp5b6, because the > authors universally declare variables "my" outside of routines, > and MacPerl promptly forgets their existence and initial values. (I > can get it working simply by removing the "my", but there's a lot of > them.) > > So is this some bizzare problem with my setup or is it a problem > with MacPerl? > --- > -------- > Paul J. Schinder > NASA Goddard Space Flight Center, > Code 693, Greenbelt, MD 20771 USA > schinder@pjstoaster.pg.md.us > >