in reply to Dealing with Lists and Arrays
I'm not sure that shift and unshift are so amazingly unique. After all, it's possible to simulate their behaviour with push and pop
Hmm, after tinkering quickly with some code, this is all I could come up with.
#!/usr/bin/perl -w my @data = qw/1 2 3 4 5/; print "Data is " . join ( ":", @data ) . "\n"; @data = reverse @data; my $foo = pop @data; @data = reverse @data; print "Data is " . join ( ":", @data ) . "\n"; @data = reverse @data; push ( @data, 17 ); @data = reverse @data; print "Data is " . join ( ":", @data ) . "\n";
So maybe shift and unshift are useful after all. Is there an easier way to simulate the behaviour that I've missed?
--t. alex
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Dealing with Lists and Arrays
by gjb (Vicar) on Nov 11, 2002 at 15:01 UTC | |
by broquaint (Abbot) on Nov 11, 2002 at 15:10 UTC |