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