home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!fmrco!fmrco!asherman
- From: asherman@laser.fmrco.com (Aaron Sherman)
- Subject: Re: fast way to get number of elements in an assoc array?
- In-Reply-To: jacobsd@prism.cs.orst.edu's message of 27 Aug 92 03:21:06 GMT
- Message-ID: <ASHERMAN.92Aug27111710@laser.fmrco.com>
- Sender: news@fmrco.uucp
- Reply-To: asherman@fmrco.COM
- Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
- References: <1992Aug27.032106.20515@CS.ORST.EDU>
- Date: Thu, 27 Aug 1992 16:17:10 GMT
- Lines: 27
-
- >>>>> jacobsd@prism.cs.orst.edu (Dana Jacobsen) said:
- Dana> Article-I.D.: CS.1992Aug27.032106.20515
- Dana> Nntp-Posting-Host: prism.cs.orst.edu
-
-
- Dana> Is there a function akin to $#array that works on associative
- Dana> arrays? I have an associative array with over 30,000 keys, and
- Dana> this is what I'm currently doing:
-
- Dana> @dummykey = keys(%records);
- Dana> print $#dummykey+1, " records loaded.\n";
- Dana> undef (@dummykey);
-
- Try:
-
- print "# of entries: ", scalar(keys %foo), "\n";
-
- Remember, arrays in a scalar context USUALLY return the number of
- items that they contain.
-
-
- -AJS
- --
- --------
- Disclaimer: I am solely responsible for the content of this message.
- The views expressed here may not be the views of I-Kinetics, Fidelity,
- any of the Fidelity-owned corporations or my mother.
-