in reply to uninitialised variable

This line clearly is doing too much at once. It can be broken down (as has already been explained) to

This may be you fooling around with Perl's syntax, or it may be a simplification of a real-world problem, but I'm hoping it's just fooling around.

Better would be

sub test { my $arg = shift; my $test = ''; defined $arg and $test = 'a'; $test .= 'b'; return $test; }
This is much longer, but I've removed the post-fix statement (personal preference); I have explicitly initialized $test; and it's now clear that the steps are 1) initialize test; 2) set test to 'a' if there was an argument; 3) append 'b' to test; and 4) explicitly return the test value.

And the best part .. when you run it, you now get

b b
as I expect you wanted.

My comments:

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.