home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 8023 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.3 KB  |  37 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!udel!bogus.sura.net!howland.reston.ans.net!usc!news.cerf.net!netlabs!lwall
  3. From: lwall@netlabs.com (Larry Wall)
  4. Subject: Re: problem with on-the-fly names
  5. Message-ID: <1993Jan27.171851.2083@netlabs.com>
  6. Sender: news@netlabs.com
  7. Nntp-Posting-Host: scalpel.netlabs.com
  8. Organization: NetLabs, Inc.
  9. References: <Jan.26.13.13.51.1993.13626@bakerst.rutgers.edu>
  10. Date: Wed, 27 Jan 1993 17:18:51 GMT
  11. Lines: 24
  12.  
  13. In article <Jan.26.13.13.51.1993.13626@bakerst.rutgers.edu> steiner@bakerst.rutgers.edu (Dave Steiner) writes:
  14. : I'm using the following in a program:
  15. : eval "\$$pname{$o} = $_";
  16. : which works fine (I'm reading printcap-like entries and creating an
  17. : assoc array for each printer with the various fields in the array).
  18. : The problem is that I don't know what fields are in the array and want
  19. : to do something like
  20. : @o = keys eval "\%$pname";
  21. : but the syntax for keys doesn't allow this!  Is there some other way I
  22. : can get all the entries in the assoc array?
  23.  
  24. @o = eval "keys %$pname";
  25.  
  26. By the way, you don't have to backwhack the %, since associative arrays
  27. don't (and won't) interpolate.  (There'd be too much confusion with
  28. printf formats if I ever made it interpolate.)
  29.  
  30. Larry
  31.