A variable declared with my is scoped until the end of it's block or if it is outside of any block, to the end of the file. Thus, this works:
package Foo; my $bar = 'Hello World'; package main; print "$bar\n";
A variable declared with our is global and can be accessed by a fully-qualified name. Example: $Foo::bar.
See perldoc perlmod for details on fully-qualified names.
In reply to Re: how to use packages as classes in perl?
by shawnhcorey
in thread how to use packages as classes in perl?
by The Elite Noob
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |