in reply to Re: Re: Usage of our
in thread Usage of our
As defined above, there is no way for anything outside the scope of MyPack to access $a. Of course, with Exporter and a few other standard class tricks, this is not hard to fix, but using Exporter for every class is a nuicence.package MyPack; my $a;
Using 'our' makes the variable known at the global scope level (that is, everyone can access it now):
Anywhere outside of MyPack, I can now get the value of $a via the variable $MyPack::a.package MyPack; our $a;
So 'our' can be considered to be declaring which variables are public in a object-oriented sense. It mostly replaces the functionality of Exporter which can be awkward to use.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Usage of our
by Anonymous Monk on May 21, 2001 at 17:25 UTC | |
|
Re: Re: Re: Re: Usage of our
by sierrathedog04 (Hermit) on May 21, 2001 at 20:25 UTC | |
by Masem (Monsignor) on May 21, 2001 at 20:27 UTC | |
by sierrathedog04 (Hermit) on May 21, 2001 at 20:43 UTC | |
by danger (Priest) on May 21, 2001 at 22:06 UTC | |
by sierrathedog04 (Hermit) on May 21, 2001 at 22:53 UTC | |
|