home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5437 < prev    next >
Encoding:
Internet Message Format  |  1992-08-22  |  1.9 KB

  1. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!smurf.sub.org!ppcnet!ppcger!Sepp
  2. Message-ID: <gkqABG@ppcger.ppc.sub.org>
  3. From: Sepp@ppcger.ppc.sub.org (Josef Wolf)
  4. Newsgroups: comp.lang.perl
  5. Subject: Re: How do you simulate a multidimensional list?
  6. Distribution: world
  7. Organization: PPC Germersheim, Germany
  8. Date: 22 Aug 92 13:52:20 GMT
  9. References: <1992Aug06.221229.265281@cs.cmu.edu> <1992Aug08.215718.25342@Celestial.COM> <1992Aug11.121132.13920@id.dth.dk>
  10. Lines: 42
  11.  
  12. In <1992Aug11.121132.13920@id.dth.dk> ej@id.dth.dk (Erik Johansen) writes:
  13. ] bill@Celestial.COM (Bill Campbell) writes:
  14. ] >:I understand that perl doesn't directly support multidimentional
  15. ] >:arrays (or lists), but that there's some way to simulate it. I don't
  16. ] >:know how to do it. I have a perl program that manipulates several sets
  17. ] >:of data, where I represent each set as a list. I'd like to make a list
  18.                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                   ^^^^^^
  19. ] >:of the lists, and use foreach over the list of lists. Below is a
  20.     ^^^^^^^^^^^^
  21. ] >:simplified example of what I'd like.
  22.  
  23. ] >can use a similar expression a{"$i,$j,$k"}.
  24.  
  25. ]  The quotes are not needed just say  $a{ $i, $j, $k } then Perl
  26.  
  27. I don't thik this are the answers the original poster was searching for.
  28. I think he's searching for something like:
  29.  
  30. @list1 = ("a1", "b1", "c1", "d1");
  31. @list2 = ("a2", "b2", "c2", "d2");
  32. @list3 = ("a3", "b3", "c3", "d3");
  33. @list4 = ("a4", "b4", "c4", "d4");
  34.  
  35. @biglist = ("list1", "list2", "list3", "list4");
  36.  
  37. foreach $list (@biglist) {
  38.   local (*alias) = $list;
  39.   foreach (@alias) {
  40.     print "$_\n";
  41.   }
  42. }
  43.  
  44. Disclaimer: never tested this, because perl not available yet for this
  45.             machine :-( 
  46.  
  47. Greetings
  48.     Sepp
  49.  
  50. -- 
  51. |   Josef Wolf,  Germersheim,  Germany    aka    sepp@ppcger.ppc.sub.org   |
  52. | +49 7274 8048  USR HST-DS  300-14400 V32/V32bis V42/V42bis/HST 24 Hours  |
  53. | ...und wieviel brave Deutsche haben wieder nichts geschnallt... (Marius) |
  54.