You're on the right track. However, lexical variables' scope is delimited by the blocks. package does not make a new scope.
Consider:
{ package Foo; my $foo; } { package Bar; my $foo; # new $foo not to be confused with one above }
Versus:
package Foo; my $foo; package Bar; my $foo; # my declaration masks previous one
In reply to Re: Why to wrap Perl classes inside a Perl script into blocks
by herveus
in thread Why to wrap Perl classes inside a Perl script into blocks
by capfan
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |