How about 

sub MySub
{
        my      ($aref)=@_;

        $count = @{$aref};

        return $count - 1;
}

HTH

John

-----Original Message-----
From: Tomasi, Chuck [mailto:[EMAIL PROTECTED]]
Sent: 20 December 2001 16:02
To: '[EMAIL PROTECTED]'
Subject: Counting the size of an array reference


For a normal array (@MyArray), one can use $#MyArray to get the position of
the last element.

So, if I'm given $MyArrayRef, how does one do the same operation to find out
how many things are in MyArrayRef?

Ex:

sub MySub
{
        my      ($aref)=@_;

        return(______);
}

my @MyArray = (0, 3, 6, 9, 154);

my $LastElement=&MySub(\@MyArray);

print "The last element is: $LastElement\n";



What goes in ___________?

--Chuck

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to