Another neat trick I use to get subroutine arguments is the old "shift"
function without an argument.
Since, @_ is the default array in a subroutine you can just say
my $firstParm = shift; #shift off the first arg from @_
Therefore,
print add(30,50);
sub addTwo{
my $firstNum = shift;
my $secondNum = shift;
return $firstNum + $secondNum;
}
will print "80". neato eh?
another fun trick if you have, say, 3 arguments is to say
my ($name, $size, $color) = @_;
this will map the first three args in your args array two the variables
$name, $size, and $color.
I hope this is useful...
-PK
-----Original Message-----
From: zentara [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 6:33 AM
To: [EMAIL PROTECTED]
Subject: Re: Changing row color with subroutine
On Fri, 22 Nov 2002 03:28:39 -0800, [EMAIL PROTECTED] (Poster) wrote:
>Hi, I am having a little trouble with a sub that is using the modulus
>operator.
Yeah, it fooled me too for a bit :-)
The problem is the way you pass the value to the
sub, @_ always is 1, the count of elements in @_.
Change @_ to @_[0] or better yet $_[0]
>--here is the sub
>sub color_rows
>{
>my $num = @_;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]