in reply to Re: map { ; ; ; } @array
in thread map { ; ; ; } @array

Considering the discussion earlier this week, the "last expression" quiz, I'd say this can get pretty interesting. If the concept of "last expression" is not well-defined, then the idiomatic usage of map can be on shaky ground as well.

Mind you, I doubt people will write the following, but it does sound poetic to include the undefined behavior:

my @foo = map { 1 for 1 } @bar;

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^3: map { ; ; ; } @array
by Anonymous Monk on Oct 21, 2005 at 20:26 UTC
    for is not an expression, so it shouldn't be suprising that it doesn't have a well-defined value. I think the document is a little vague, but people seem to be hung up on the sentence...
    "The return value of the subroutine is the value of the last expression evaluated."
    ...which probably should be modified to something like...
    "The return value of the subroutine is the value of the last syntatic expression."
      for is not an expression
      No, but Perl does have a construct to turn any statement into an expression, and it's called do.
      @foo = map {do {1 for 1}} @bar;
      Perl --((8:>*