home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!dkuug!cri.dk!id.dth.dk!ej
- From: ej@id.dth.dk (Erik Johansen)
- Newsgroups: comp.lang.perl
- Subject: Re: Multi-dimensional arrays
- Message-ID: <ej.722264919@id.dth.dk>
- Date: 20 Nov 92 13:08:39 GMT
- References: <sasswb.722021479@k2> <mcook.722100428@fendahl.dev.cdx.mot.com>
- Organization: Department of Computer Science
- Lines: 27
-
- >sasswb@unx.sas.com (Scott Bass) writes:
-
- >>1. How can I code a multi-dimensional array in perl, say an Nx5 array?
-
- >You can do it the same way you could in any language:
-
- > $foo[$i * 5 + $j] = $bar;
-
- Another way is to use assoc. arrays like this
-
- $foo{ $i, $j } = $bar;
-
- Here the indexes $i, $j does not have to be numbers. It can be any name
- or string (as long as it does not contain $, )
-
-
- Hope this helps
- Erik Johansen
-
- ---
- Erik Johansen / Institute for Computer Science / Danish Technical University
- ej@id.dth.dk
- $txt=" ltrterhnuc--sor eep-\nkJ.a "; srand(53747414);
- for (1..26) { print substr($txt,rand 27,1); } ### Is this a random write ?
- --
- Erik Johansen / Institute for Computer Science / Danish Technical University
- ej@id.dth.dk
-