dReKurCe has asked for the wisdom of the Perl Monks concerning the following question:
Produces the following output:#! /usr/bin/perl for $num(0..42){ foo($num); sub foo{ print "input to sub=@_\n"; if (@_== 0){ print "test for zero is accurate\n"; } elsif(@_== 1){ print "test for one is accurate\n"; } else{ print "Composing mortals with immortal fire. \n"; } } }
Furthermore , using refs to the sub input as such :input to sub=0 test for one is accurate input to sub=1 test for one is accurate input to sub=2 test for one is accurate
generates:if (\@_ == 0) and if (\@_ ==1)
this is the same result for the entier range! Any input on the test and the nature of references would be greatly appreciated. Thanks Monks!input to sub=0 Composing mortals with immortal fire.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Subroutine Behaviour
by merlyn (Sage) on Sep 25, 2004 at 02:48 UTC | |
|
Re: Subroutine Behaviour
by TheEnigma (Pilgrim) on Sep 25, 2004 at 03:14 UTC | |
|
Re: Subroutine Behaviour
by ikegami (Patriarch) on Sep 25, 2004 at 04:30 UTC | |
by saberworks (Curate) on Sep 25, 2004 at 20:31 UTC | |
|
Re: Subroutine Behaviour
by jdalbec (Deacon) on Sep 25, 2004 at 03:20 UTC | |
by ysth (Canon) on Sep 26, 2004 at 06:42 UTC |