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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!swrinde!cs.utexas.edu!sdd.hp.com!spool.mu.edu!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!ames!sgi!wdl1!wdl39!mab
  3. From: mab@wdl39.wdl.loral.com (Mark A Biggar)
  4. Subject: Re: problem with on-the-fly names
  5. Message-ID: <1993Jan27.181856.12690@wdl.loral.com>
  6. Sender: news@wdl.loral.com
  7. Organization: Loral Western Development Labs
  8. References: <Jan.26.13.13.51.1993.13626@bakerst.rutgers.edu>
  9. Date: Wed, 27 Jan 1993 18:18:56 GMT
  10. Lines: 20
  11.  
  12. In article <Jan.26.13.13.51.1993.13626@bakerst.rutgers.edu> steiner@bakerst.rutgers.edu (Dave Steiner) writes:
  13. >I'm using the following in a program:
  14. >eval "\$$pname{$o} = $_";
  15. >which works fine (I'm reading printcap-like entries and creating an
  16. >assoc array for each printer with the various fields in the array).
  17. >The problem is that I don't know what fields are in the array and want
  18. >to do something like
  19. >@o = keys eval "\%$pname";
  20. >but the syntax for keys doesn't allow this!  Is there some other way I
  21. >can get all the entries in the assoc array?
  22.  
  23.  Sure just move the kes inside the eval like so:
  24.  
  25. @o = eval "keys \%$pname";
  26.  
  27. --
  28. Perl's Maternal Uncle
  29. Mark Biggar
  30. mab@wdl1.wdl.loral.com
  31.  
  32.