Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.lang.perl Subject: Re: associative arrays of arrays Message-ID: <1991Feb26.010557.2905@NCoast.ORG> Date: 26 Feb 91 01:05:57 GMT References: <1991Feb21.051208.21101@mlb.semi.harris.com> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.lang.perl Organization: North Coast Public Access Un*x (ncoast) Lines: 46 As quoted from <1991Feb21.051208.21101@mlb.semi.harris.com> by jdr@sloth.mlb.semi.harris.com (Jim Ray): +--------------- | I would like to build an associative array which in turn points to | lists ( one per key ). | | $array{$name} = SOME LIST | Where SOME LIST is some array ( list ) of indices into another set | of arrays containing relivant record information. This array | would be periodically added to while traversing the entire | list of people. +--------------- Perl doesn't support it per se; the usual solution is to store it as a string or in other variables and use eval. Me, in my latest abomination (about which more later, I see something about it in a later thread) I found a need for lists of lists. So, with a little hacking, I came up with this monstrosity: $gensym = 'gensym00000000000'; sub pushlist { local(*l1, @l2) = @_; local(*sym) = $gensym++; @sym = @l2; push(@l1, *sym); } sub poplist { local(*l1) = @_; local(*sym) = pop(@l1); @sym; } Similar routines can be written for shift and unshift. ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY