in reply to what does shift do?
So, if you have an array, initialized like this:
my @a = ( 'a', 'b', 'c'); my $x = shift @a;
then after this code executes, $x will contain the scalar value, 'a', and @a will contain, ( 'b', 'c' ).
In lexical scope (i.e., within a subroutine), shift by itself, without any arguments, implicitly acts upon the variable @_, which contains the subroutine's arguments.
At file scope (i.e., outside of any subroutine), it implicitly operates instead upon @ARGV (also known as ::@ARGV, or main::@ARGV), which contains the command line parameters passed to the script.
See the docs, "shift".
dmm
There are no stupid questions -- just stupid-making responses
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: what does shift do?
by dev2000 (Sexton) on May 19, 2002 at 20:36 UTC | |
by Juerd (Abbot) on May 19, 2002 at 20:48 UTC | |
by dmmiller2k (Chaplain) on May 19, 2002 at 20:41 UTC | |
by Juerd (Abbot) on May 19, 2002 at 20:52 UTC |