This is not about "fusion", it's about confusion.
I have absolutely no clue about what exactly you are trying to achieve, but maybe it helps you to point out that "my"-variables are lexically scoped and that means that they are only visible within the nearest "{"-block.
And if you stack my-declarations you simply shadow previous ones.
Consider this:
use strict;
my $whatever = "outer";
if (1) {
my $whatever = "inner";
print "$whatever\n";
}
print "$whatever\n";
Here you have a lexically-scoped variable in the outer scope and the same one in the scope introduced by if.
Within the if-block $whatever is changed to "inner", and that is what is printed from the print there, but once you leave this scope you refer to the outer definition and so the outer print prints "outer" (what else?).
In your case you have "my $test" in the outer scope.
Then you introduce a new scope with "if" and declare a new variable with "my $test" and set that to "GOOD". Here you shadow the already introduced variable. Later (in another if-scope) you introduce yet another variable (again shadowing the outer one) and that of course knows nothing about the assignment you did in another scope.
Short story:
You are dealing with three different variables here: The outer $test, the $test in the first if and the $test in the second if.
This probably was confusing - sorry for that but I am a bit drunk...
|