On 13 Nov 2005 at 19:19, Dylan Stamat wrote: > No, not the routine that deals with Arrays ! > > I see code like the following, everywhere: > my $coolvariable = shift; > > Why is a new scalar being assigned to "shift" ? > New to Perl... sorry for the lame question, but couldn't find an answer > anywhere.
shift does deal with arrays. So $coolvariable is has the first element of whatever array you passed to the function: sub mysub { my $first_element = shift; my $second_element = shift; print "One=$first_element, Two=$second_element\n"; } You see shift a lot at the start of scripts too. It's how you take in command-line arguments (the array @ARGV) . So #!/usr/bin/perl -w # name.pl # use strict; my $name = shift; print "Your name is $name\n"; > ./name.pl joe prints joe. HTH. Dp. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>