masood91 has asked for the wisdom of the Perl Monks concerning the following question:
I am facing some sifficulties in understanding use of @_ in perl subroutines. @_ is a default array in which arguments passed to a subroutine are stored. Right, then why not use this staement for getting those arguments
my $a=@_ Why we use shift? look at this line of code..abc(3271); sub abc{ my $a=shift; #what is it? why are we shifting?? }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: difficulty in understanding use of @_ and shift in a subroutine
by Athanasius (Archbishop) on Oct 27, 2014 at 06:17 UTC | |
|
Re: difficulty in understanding use of @_ and shift in a subroutine
by Loops (Curate) on Oct 27, 2014 at 06:13 UTC | |
by masood91 (Novice) on Oct 27, 2014 at 06:19 UTC | |
by perlron (Pilgrim) on Oct 27, 2014 at 06:59 UTC | |
|
Re: difficulty in understanding use of @_ and shift in a subroutine
by johngg (Canon) on Oct 27, 2014 at 10:24 UTC |