in reply to local our $var; What does it do?

our $foo aliases $foo to $CURRENT_PACKAGE::foo.

local $foo backs up the value of $foo and causes the backup to be restored when the current lexical scoped it existed.

our $foo returns $foo, so local our $foo is the same as our $foo; local $foo.

Basically local our $foo the closest approximation possible of my $foo, but using package variables instead of lexical variables. I have no idea why you'd want to do that.


Update: I previously had an example that used local our @ARGV = @args;, but that should be just local @ARGV = @args;.

Replies are listed 'Best First'.
Re^2: local our $var; What does it do?
by kcott (Archbishop) on Jun 18, 2015 at 17:20 UTC

    Thanks for the explanation ...

    ... which has grown since I hit [reply] — obviously you're still typing.

    Thanks in advance for any more you type; but I can only upvote once. :-)

    Update: Oh dear, it's shrunk back to almost it's original size. I'll go away and make a cup of tea and wait for this dynamic post to reach a state of quiescence. :-)

    -- Ken