in reply to Re^7: Help! My variables are jumping off a cliff!
in thread Help! My variables are jumping off a cliff!

dave_the_m's example leads to a very practical, if slightly contrived use for double declaration.

You have a sub that returns two subrefs. Those two subrefs are, as you might assume from their being instantiated at the same time, related. And they both rely upon a variable of some domain specific name that they inherit through closure. But they each need a different one:

sub generator { ... my $frobnosticator = 0; my $coderef1 = sub{ ...; $frobnosticator ^= 1; ... }; my $frobnosticator = 0; my $coderef1 = sub{ ...; $frobnosticator ^= 1; ... }; return $coderef1, $coderef2; }

There, perfectly sensible :)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?