Any variable you see that has a double colon (Foo::bar) or apostrophe (Foo'bar) in it is a package variable. Any variable created with my is not a package variable.
$ perl -le' use warnings; use strict; package Foo; # this creates a package called Foo my $Foo::bar = "Hello World"; ' "my" variable $Foo::bar can't be in a package at -e line 6, near "my $ +Foo::bar " Execution of -e aborted due to compilation errors.
$ perl -le' use warnings; use strict; package Foo; # this creates a package called Foo $Foo::bar = "Hello World"; package main; # goes back to default package of class print $Foo::bar; # this prints $bar form package Foo ' Hello World
In reply to Re: how to use packages as classes in perl?
by jwkrahn
in thread how to use packages as classes in perl?
by The Elite Noob
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |