It looks like an obscure case of list context biting you. Take a look at the warnings about \(@foo) in the perlref man page to see what I mean. Maybe your code is using the return value in a list context in the third spot? I would probably throw in some wantarray() checks to see if that's the difference, and maybe break out the debugger.