in reply to sub argument passing? (TIMTOWTDI)
There is another approach to this problem: prototyping.
#!/usr/bin/perl use warnings; use strict; #prototyped to explicitly state acceptable arguments sub addstuff($$$); my $D=4; my $E=3; my $F=2; #gives error if too few or too many arguments #(or arguements of wrong type) my $result = addstuff $D, $E, $F; print $result."\n"; #prototyped to match sub addstuff($$$){ my $A=shift; my $B=shift; my $C=shift; return $A+$B+$C; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: sub argument passing? (TIMTOWTDI)
by AnomalousMonk (Archbishop) on Sep 17, 2012 at 21:04 UTC | |
by temporal (Pilgrim) on Sep 17, 2012 at 21:45 UTC | |
Re^2: sub argument passing? (TIMTOWTDI)
by temporal (Pilgrim) on Sep 17, 2012 at 14:58 UTC | |
by choroba (Cardinal) on Sep 17, 2012 at 15:02 UTC | |
by protist (Monk) on Sep 17, 2012 at 16:13 UTC | |
by AnomalousMonk (Archbishop) on Sep 17, 2012 at 21:10 UTC | |
by protist (Monk) on Sep 17, 2012 at 16:11 UTC |
In Section
Seekers of Perl Wisdom