<br><font size=2 face="sans-serif">We are having way too much fun with
this. Good comment on commenting Brian! Yitzchak has appropriately
responded for me. But I think the term "drain", that I
did not use first, but, none the less has now been twisted. The first
use of the word "drain" in the context of this discussion came
from the shift/pop solution, where the array was prematurely "drain"ed
from the shift, leaving nothing to pop, causing $last to be undefined.
So the term drain was someone else used to describe the emptying
of an array through the use of shift and pop. I pointed out that
the slice solution does not drain anything because it merely accesses two
elements, nondestructively to the array, which in this case was anonymous
and lost anyway. The split, as others have pointed out, had nothing
to do with it, as it only created the array from a string, and was not
being used directly to populate $first and $last.</font>
<br>
<br><font size=2 face="sans-serif"><br>
---<br>
Rick Croote<br>
Software Engineer<br>
Environment and Tools Team<br>
Philips Medical Systems<br>
Bothell, WA<br>
Rick.Croote@Philips.com<br>
Phone: 425-487-7834<br>
</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=33%>
<br>
<br>
<br>
<br>
<br><font size=1 face="sans-serif"><b>Yitzchak Scott-Thoennes</b> </font>
<p><font size=1 face="sans-serif">Sent by:</font>
<br><font size=1 face="sans-serif">spug-list-bounces@pm.org</font>
<p><font size=1 face="sans-serif">2005-06-30 10:49 AM</font>
<td width=66%>
<table width=100%>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td valign=top><font size=1 face="sans-serif">"DeRykus, Charles E"
<charles.e.derykus@boeing.com></font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top><font size=1 face="sans-serif">spug-list@mail.pm.org</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">Re: SPUG: spug: What is the
idiomatic way toextractfirst/lastitemafter
split?</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Classification</font></div>
<td></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<div align=right>
<br></div></table>
<br>
<br>
<br><font size=2><tt>On Thu, Jun 30, 2005 at 09:28:06AM -0700, DeRykus,
Charles E wrote:<br>
> Ok, I characterized this as a "drain" because, superficially
at<br>
> least, you're filling a bigger bucket with a smaller one. The
split<br>
> output consists of a single item but the Action of the function<br>
> split populates $first with that single item; and then backfills<br>
> $last with an undef. Here's what I assume Rick was referring to in<br>
> claiming that no "drain" occurred:<br>
> <br>
> perdoc -f split:<br>
> <br>
> When assigning to a list, if LIMIT is omitted,
Perl supplies a LIMIT<br>
> one larger than the number of variables in the
list, to avoid<br>
> unnecessary work. <br>
> <br>
> <br>
> perl -MO=Deparse -e '($first,$last) = split("
","foo");'<br>
> ($first, $last) = split(" ", 'foo',
3);<br>
> <br>
> <br>
> The split really generates only 1 element; behind the scenes, split<br>
> orchestrates output so $first gets populated with that 1 element and<br>
> then $last gets backfilled with an 'undef' because the original list<br>
> is exhausted. Maybe that seat-of-the-pants explanation is flawed<br>
> somehow...<br>
> <br>
> I assume Rick felt that because split generates values for both<br>
> $first and $last this shouldn't be thought of as a "drain".
To me,<br>
> it just seems natural to call it a "drain" because there's
really a<br>
> 1 item output and that's trying to fill 2 slots.<br>
<br>
But the case under consideration isn't ($first, $last) = split ...;,<br>
it's ($first, $last) = ( split ... )[0, -1]; which indeed never leaves<br>
$last undefined. If only one element is produced by split, both<br>
$first and $last get assigned that value.<br>
_____________________________________________________________<br>
Seattle Perl Users Group Mailing List <br>
POST TO: spug-list@pm.org<br>
SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list<br>
MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med<br>
WEB PAGE: http://seattleperl.org/<br>
</tt></font>
<br>