Not commenting on the exact behavior of Perl, but I have a coding style suggestion.
in reply to Perl: last evaluated value as a returned value for a subroutine. See inside
Perl's feature of returning the last evaluated value can be handy when you're writing quick code (or perhaps when you're golfing). But the code you wrote above is not very clear. Hand that to other programmers and I bet many won't know the return value - even plenty of Perl veterans.
Just because you can do something doesn't mean you should. Write more explicit code. For everyone's sake (including yourself a week/month/year in the future).