Jorge Almeida wrote: > I thought I already knew a few things about Perl, but I just found out I > don't: > #!/usr/bin/perl -w > use strict; > use diagnostics; > my $a="27"; > doit(); > sub doit{ > print "$a\n"; > } > > The output of this program is: > 27 > > Just what I would expect if line 4 had "our" instead of "my". > What am I missing?
my() and our() have the same scoping so they will behave the same. my() variables are scoped from the point they are declared up to the end of the current file/block. Since your variable is not inside a block it is visible throughout the rest of the file. By the way, you shouldn't use $a or $b as they are "special" variables. perldoc -f sort perldoc perlvar John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>