in reply to How can I use the the return value of split without assigning?
You can get the "car" (couldn't they have thought of a better name?) of an array like this:
@x[1..$#x]
But that's ugly and probably inefficient. And you have to actually assign your list to @x first, so you can't wedge it into the middle of an expression. Too bad you can't give an open-ended array slice, like this:
(split / /, $string)[1..]
Perl arrays are different from lisp lists. Some things that are easy with one may not be easy with the other. How could it be otherwise?
Update: Did I get car and cdr mixed up again? I can't imagine how I could be so careless. Contents of address register, contents of decrement register - the difference couldn't be clearer!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How can I use the the return value of split without assigning?
by hding (Chaplain) on Jul 27, 2001 at 05:59 UTC |