home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7078 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  1.1 KB

  1. Path: sparky!uunet!mcsun!sunic!dkuug!cri.dk!id.dth.dk!ej
  2. From: ej@id.dth.dk (Erik Johansen)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Multi-dimensional arrays
  5. Message-ID: <ej.722264919@id.dth.dk>
  6. Date: 20 Nov 92 13:08:39 GMT
  7. References: <sasswb.722021479@k2> <mcook.722100428@fendahl.dev.cdx.mot.com>
  8. Organization: Department of Computer Science
  9. Lines: 27
  10.  
  11. >sasswb@unx.sas.com (Scott Bass) writes:
  12.  
  13. >>1.  How can I code a multi-dimensional array in perl, say an Nx5 array?
  14.  
  15. >You can do it the same way you could in any language:
  16.  
  17. >    $foo[$i * 5 + $j] = $bar;
  18.  
  19. Another way is to use assoc. arrays like this
  20.  
  21.         $foo{ $i, $j } = $bar;
  22.  
  23. Here the indexes $i, $j does not have to be numbers. It can be any name
  24. or string (as long as it does not contain $, )
  25.  
  26.  
  27.   Hope this helps
  28.   Erik Johansen
  29.  
  30. ---
  31. Erik Johansen / Institute for Computer Science / Danish Technical University
  32. ej@id.dth.dk
  33.     $txt=" ltrterhnuc--sor eep-\nkJ.a "; srand(53747414);
  34.     for (1..26) { print substr($txt,rand 27,1); }  ### Is this a random write ?
  35. -- 
  36. Erik Johansen / Institute for Computer Science / Danish Technical University
  37. ej@id.dth.dk
  38.