sub foo {
local $SWAP = 1;
alias $alias => $original;
...
Module::bar(some,params);
...
}
and someone else in the Module writessub bar {
alias $original => $alias;
...
}
And suddenly his/her code starts trying to do something else than it should. Just because it was called from my foo() instead of directly. The local() could only "help" if I used it like this:
sub foo {
{local $SWAP = 1;alias $alias => $original;}
...
}
But that's to long. I'd need the $SWAP to be lexical to my whole file, not local to the current call/block stack.
I think the nicest solution is alias $original => $alias; and Alias $alias => $original;.
Or maybe I should just learn it's the other way around versus what I'd expect :-)
Jenda
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne
Edit by castaway: Closed small tag in signature |