jeteve has asked for the wisdom of the Perl Monks concerning the following question:
A question stroke me recently, what could be a legitimate use of both 'local' and 'our' on a variable in a package?
I wrote the following code to try to figure it out:
package Foo; use strict; use warnings; local our $V; sub print_v{ print $V."\n"; } 1; package main; use strict; use warnings; $Foo::V = 'Blabla'; print $Foo::V."\n"; Foo::print_v();
It prints 'Blabla' twice and removing the 'local' on $V doesn't make any difference.
Can you think about any situation where local-izing an 'our' variable could be useful?
-- Jerome Eteve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Legitimate use for combined 'local' and 'our'
by JavaFan (Canon) on Nov 15, 2010 at 10:57 UTC | |
|
Re: Legitimate use for combined 'local' and 'our'
by moritz (Cardinal) on Nov 15, 2010 at 10:48 UTC | |
by JavaFan (Canon) on Nov 15, 2010 at 11:02 UTC | |
|
Re: Legitimate use for combined 'local' and 'our'
by jettero (Monsignor) on Nov 15, 2010 at 11:04 UTC |