[prog] More Perl questions

Dan Richter daniel.richter at wimba.com
Thu Jun 5 13:18:07 EST 2003


I was reading some documentation about a Perl function that returns a list 
of items in list context, but only returns the first item in scalar context.

Now, I understand that in Perl, an array can be treated as a scalar (in 
which case it returns the index of the last element in the array). But 
that's not what this function does: it returns a list in list context, but 
only the first item if it's called in scalar context.

How does that work?

========== Dan Richter ============== mailto:Dan at wimba.com ===========
  [Larry] Wall [inventor of Perl] believes that people think about
  things in different ways, that natural languages accommodate many
  mindsets, and that programming languages should too.
    - Jon Udell, in his essay, "A Perl Hacker in the Land of Python"



More information about the Programming mailing list