home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5545 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.3 KB  |  41 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!fmrco!fmrco!asherman
  3. From: asherman@laser.fmrco.com (Aaron Sherman)
  4. Subject: Re: fast way to get number of elements in an assoc array?
  5. In-Reply-To: jacobsd@prism.cs.orst.edu's message of 27 Aug 92 03:21:06 GMT
  6. Message-ID: <ASHERMAN.92Aug27111710@laser.fmrco.com>
  7. Sender: news@fmrco.uucp
  8. Reply-To: asherman@fmrco.COM
  9. Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
  10. References: <1992Aug27.032106.20515@CS.ORST.EDU>
  11. Date: Thu, 27 Aug 1992 16:17:10 GMT
  12. Lines: 27
  13.  
  14. >>>>> jacobsd@prism.cs.orst.edu (Dana Jacobsen) said:
  15. Dana> Article-I.D.: CS.1992Aug27.032106.20515
  16. Dana> Nntp-Posting-Host: prism.cs.orst.edu
  17.  
  18.  
  19. Dana>   Is there a function akin to $#array that works on associative
  20. Dana> arrays? I have an associative array with over 30,000 keys, and
  21. Dana> this is what I'm currently doing:
  22.  
  23. Dana>    @dummykey = keys(%records);
  24. Dana>    print $#dummykey+1, " records loaded.\n";
  25. Dana>    undef (@dummykey);
  26.  
  27. Try:
  28.  
  29.         print "# of entries: ", scalar(keys %foo), "\n";
  30.  
  31. Remember, arrays in a scalar context USUALLY return the number of
  32. items that they contain. 
  33.  
  34.  
  35.             -AJS
  36. --
  37. --------
  38. Disclaimer: I am solely responsible for the content of this message.
  39. The views expressed here may not be the views of I-Kinetics, Fidelity,
  40. any of the Fidelity-owned corporations or my mother.
  41.