Curly braces can be used either to create hashes or to enclose code blocks. Perl tries to figure out which you mean and is usually right, but sometimes it guesses wrong. It's not a "bug", per se; you just need to add the return or otherwise disambiguate what it is that you want.