in reply to head of list + rest of list
Perl allows many ways, depending on whether you want Haskell-style list partition, or imperative list manipulation:
# Haskell programmer: my ($head,@tail) = @list; # Shell programmer my ($head) = shift @list; my @tail = @list; # Perlfunc Author ($head) = splice @list, 0, 1; @tail = @list;
Put $head in list context for the splice example
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: head of list + rest of list
by merlyn (Sage) on May 18, 2005 at 18:07 UTC | |
|
Re^2: head of list + rest of list
by mrborisguy (Hermit) on May 18, 2005 at 18:25 UTC | |
by merlyn (Sage) on May 18, 2005 at 18:30 UTC | |
by lkundrak (Novice) on Jul 14, 2014 at 08:53 UTC | |
|
Re^2: head of list + rest of list
by ikegami (Patriarch) on May 18, 2005 at 18:46 UTC |