News for hackers. Stuff that matters.
Re:Differences Between Perl 5 and Perl 6 by xorcist on Wednesday October 07, 2015 @12:08PM (#10346840)
Every Perl expression has a context, and context is as central to Perl as types are to some other languages. It's first chapter material in any Perl book. It's not "overloading on return type" strictly speaking, but that's what the syntax looks like.

An array (of characters in your example) in a scalar context is the length of the array. I don't know if that's whats happening here, but that's how you do it everywhere else in Perl so it would make sense to do it on strings too.

Re:Differences Between Perl 5 and Perl 6 by philh on Wednesday October 07, 2015 @01:39PM (#10347540)
Perl6 doesn't do this. A function doesn't know if it's being called in scalar or list context.

(I think there might be some movement towards letting a function detect sink (void) context. Then functions with both side effects and return values don't need to calculate the return values when they aren't needed.)