in reply to Legitimate use for combined 'local' and 'our'
Running this gives output:package Foo; use 5.012; use strict; use warnings; $Foo::V = "fred"; { local our $V = "waldo"; say $V; sub bar {say $V}; sub set_v {$V = shift}; } package Baz; Foo::bar; Foo::set_v "fnord"; Foo::bar; __END__
Removing the local, and running it gives:waldo fred fnord
And it won't compile if, instead of removing the local, you remove the our.waldo waldo fnord
Of course, you may argue this code isn't very useful, but it does show there can be differences between local, our and local our. Given that I don't use our much (typically just for @ISA, and @EXPORT and friends), and neither local, I don't think I've ever had the need to use local our.
|
|---|