SPUG: spug: What is the idiomatic way to extractfirst/lastitemafter split?

Colin Meyer cmeyer at helvella.org
Thu Jun 30 10:52:51 PDT 2005

On Thu, Jun 30, 2005 at 10:49:41AM -0700, Yitzchak Scott-Thoennes wrote:
> But the case under consideration isn't ($first, $last) = split ...;,
> it's ($first, $last) = ( split ... )[0, -1]; which indeed never leaves
> $last undefined.  If only one element is produced by split, both
> $first and $last get assigned that value.

$last (and $first) will be undefined if split returns an empty list. :)


More information about the spug-list mailing list