jas@ISI.EDU (Jeff Sullivan) (02/16/91)
Well, I've gotten down the basics of my earlier query, but there's one thing I can't figure out how to do. I have a usage of the abbrev.pl library liek this: %attr = (); &abbrev(*attr, @tmp); Which fills the associative array %attr with all of the possible unique abbreviations of the words in the array @tmp. Now, what I want to do is put this in a foreach loop, so I just have to list the files I want in one place, and iterate over them like so: $filename will hold the name of the current file of commands being read into @tmp. $filestub will hold a subset of $filename, which is the name of the associative array I want (in the top most example, $filename would be "ATTR-LIST", and $filestub would be "ATTR"). Then, I want to be able to do this: %$filestub = (); #set the assoc array named in $filestub to null. &abbrev(*$filestub, @tmp); # set the associative array named in # $filestub to the abbreviations alist. How do I do it? jas -- -------------------------------------------------------------------------- Jeffrey A. Sullivan | Senior Systems Programmer jas@venera.isi.edu | Information Sciences Institute jas@isi.edu | University of Southern California
tchrist@convex.COM (Tom Christiansen) (02/16/91)
From the keyboard of jas@ISI.EDU (Jeff Sullivan): :Then, I want to be able to do this: : :%$filestub = (); #set the assoc array named in $filestub to null. :&abbrev(*$filestub, @tmp); # set the associative array named in Untested: eval <<EOCODE; %$filestub = (); #set the assoc array named in $filestub to null. &abbrev(*$filestub, \@tmp); # set the associative array named in EOCODE The point is that when doing things like $$foo or %$foo, you need to force an explicit eval. Only with &$foo can you get away with nothing so. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "All things are possible, but not all expedient." (in life, UNIX, and perl)