in reply to Re: Need to check my understanding of this code...
in thread Need to check my understanding of this code...
Not quite. Shift removes the first entry from the list, a simple assignment doesn't (although since that list is never used again, in this context it makes no difference - except that the assignment is slightly faster). Compare:
#!/usr/bin/perl use strict; use warnings; my @list = qw/a b c/; my ($x) = @list; print "X: $x, List: @list\n"; my $y = shift @list; print "Y: $y, List: @list\n";
The output being:
X: a, List: a b c Y: a, List: b c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Need to check my understanding of this code...
by borisz (Canon) on Sep 04, 2005 at 19:36 UTC | |
by dorward (Curate) on Sep 04, 2005 at 23:25 UTC |