nallasiv has asked for the wisdom of the Perl Monks concerning the following question:
I tried using Shift() in PERL and it is not working when I use it in a PERL root program. But when I declare a function in the program and use Shift() in that it is working. Can anyone say why is it so?
The following is the program.
#!/usr/bin/perl -w shift @ARGV; # here its is not working print ; sub func { my $a=shift; # here its is working my $b=shift; print $a,$b; return $a+$b; } print func(10,10);
20040503 Edit by Corion: added formatting
I have used like that because in the book "Perl Weekend Crash Course" by Joe Merlino the code was given in Session 11 - Basic Input and Output.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Usage of Shift function in PERL
by bart (Canon) on May 03, 2004 at 10:35 UTC | |
by Abigail-II (Bishop) on May 03, 2004 at 11:45 UTC | |
|
Re: Usage of Shift function in PERL
by perlinux (Deacon) on May 03, 2004 at 10:40 UTC | |
by nallasiv (Initiate) on May 03, 2004 at 10:50 UTC | |
|
Re: Usage of Shift function in PERL
by Corion (Patriarch) on May 03, 2004 at 10:48 UTC | |
|
Re: Usage of Shift function in PERL
by matija (Priest) on May 03, 2004 at 10:43 UTC | |
|
Re: Usage of Shift function in PERL
by virtualsue (Vicar) on May 03, 2004 at 13:03 UTC |