Hi Perl buddies, Can I do something like this:
my $line = 'One Two Three Four Five Six'; my( $first, $last ) = (split(' ', $line))[0,$#(split(' ', $line))]; This does not work. What I want to do is to find the index of the last element of a list created by split, and use it in a slice on the same line. Wow, that sounds garbled when I re-read it. With the above example, I want the two variables to contain the following: $first = 'One'; $last = 'Six'; I realize I can do this in two steps: my $line = 'One Two Three Four Five Six'; my @line = split(' ', $line); my($first, $last) = @line[0,$#line]; But I was wondering if it can be done on one line. --Errin PS ---- oops ... I just remembered negative indexing. This works: my $line = 'One Two Three Four Five Six'; my( $first, $last ) = (split(' ', $line )[0, -1]; Weeeeeeeeeeeeeeeee! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>