$new::variable is a package variable belonging to the 'new' package (bad name btw). $another_variable is a lexical variable that you need to declare using 'my' because you are using strictures (use strict; use warnings; - highly recommended btw). The fix is just:
use strict; use warnings; use MyPackage; $MyPackage::variable = 1; my $another_variable = 2;
Note that if package MyPackage uses strict it will need to declare $variable using our:
use MyPackage; use strict; use warnings; our $variable = 1;
In reply to Re: Variable declaration
by GrandFather
in thread Variable declaration
by nagalenoj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |