in reply to uninitialised variable

Declaring a variable in a conditional statement has undefined behaviour, and should not be used. From perlsyn:

"NOTE: The behaviour of a my, state, or our modified with a statement modifier conditional or loop construct (for example, my $x if ... ) is undefined. The value of the my variable may be undef, any previously assigned value, or possibly anything else. Don't rely on it. Future versions of perl might do something different from the version of perl you try it out on. Here be dragons."

update: The code would be better written along the following lines:

sub test { my $var = shift; my $test; $test = 'a' if defined $var; $test .= 'b'; }