On Wed, 20 Feb 2002, Nestor Florez wrote: > I was wondering about the "shift" inside a subroutine. > > I have never used it. What is the purpose of it been there?
It pulls off the first element of the array passed to it. Using shift with no arguments always pulls from @_ -- it returns $_[0] and also shifts the other elements down ($_[1] becomes $_[0], $_[2] becomes $_[1], etc). @_ is the 'default' array (analogous to $_), and in a subroutine, is the array of subroutine arguments. If you say mysub('arg1', 'arg2'); then sub mysub { $arg1 = shift; #gets the first argument 'arg1' $arg2 = shift; #gets the second argument 'arg2' ... } -- Brett http://www.chapelperilous.net/ ------------------------------------------------------------------------ Computer programmers never die, they just get lost in the processing. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]