http://www.perlmonks.org?node_id=720232


in reply to Re^5: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands

In most simpler syntactic constructs, though, I think perl just does what the author of the code expects with the Perl they wrote. In the interests of maintainability, most of the more complex issues of context don't come up in most of the code I write or see from others.

There are a few immensely important idioms that make use of mixing expressions in list and scalar context in the same statement very useful, but if one thinks of them as "idioms", they're likely not to question the specifics. An idiom is something that doesn't necessarily translate directly to other languages by definition, after all.

We've been using contrived examples in which we're taking the length of static-length lists. They could have been arrays, but those arrays still could have had their lengths computed in a separate statement.

  • Comment on Re^6: If you believe in Lists in Scalar Context, Clap your Hands