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

Bill Campbell bill at celestial.com
Wed Jun 29 11:25:03 PDT 2005


On Wed, Jun 29, 2005, Rick Croote wrote:
...
>   Not true, the slice "[0,-1]" does not "drain", but just reuses the
>   same element in the case of one element after the split.  This then
>   creates the appropriate 2 elements to initialize $first and $last.  Of
>   course, $string must be initialized to something other than what it
>   would split on.  I lost track of who posted this solution, you say J.
>   Krahn, I say, very nice solution J. Krahn.  You gotta love elegant one
>   line solutions :)

``Elegant one-line solutions'' are fine -- if it's evident what
it is you're doing.  The problem is when one is looking at code
that somebody else wrote to figure out what they're doing (and
that includes my own code if I haven't looked at it recently :-).

One of the problems with perl is that it has lots of magic, and
it's not always evident what is being done unless the code is
well commented.  Even with good comments, it can be confusing.

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``the purpose of government is to reign in the rights of the people''
    -Bill Clinton during an interview on MTV in 1993


More information about the spug-list mailing list