molly has asked for the wisdom of the Perl Monks concerning the following question:
I have yet another general question. I'm working on debugging a perl program, and have been having to do a lot of reverse-engineering. With my primitive understanding of Perl this has been difficult, but I think I'm almost there. I just need (maybe) one piece of crucial information. Here is the subroutine I'm looking at:
sub SearchPubMed { my $InputRow = shift; # temporary! InputRow = SearchTermID my $QueryID = shift; my $CannedQueriesPurpose = shift; my $CannedQueriesQuery = shift; my $query;
What exactly does it mean to define variables as shift? I understand that the shift operator grabs the first element of an array, and that when "shift" appears next to white space, it is assumed that it is grabbing from the @_ special array variable. I don't totally understand where @_ has come from here and what is stored in it. Can someone shed some light onto the @_ special variable for me? Thanks oodles.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: shift operator
by GrandFather (Saint) on Jul 23, 2007 at 22:49 UTC | |
|
Re: shift operator
by saintly (Scribe) on Jul 23, 2007 at 22:40 UTC | |
|
Re: shift operator
by FunkyMonk (Bishop) on Jul 23, 2007 at 22:41 UTC | |
|
Re: shift operator
by Zaxo (Archbishop) on Jul 24, 2007 at 06:30 UTC |