Hacker News new | past | comments | ask | show | jobs | submit login

An interesting nuance, which many early Perl teaching books up until Modern Perl [1] failed to address properly is "context". Perl allows both single and multi-value function return. In return the function can ask whether the calling statement expects a single or multiple values. Additionally, this request for expectation propagates through the call stack from the first statement where this can be correctly determined, to the place where the question was asked.

This makes it possible to do things like this:

   my $first = max( 1, 2, 3, 4, 5 );

   my ( $first, $second, $third ) = max( 1, 2, 3, 4, 5 );
[1] http://onyxneon.com/books/modern_perl/



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: