MESSAGE
DATE | 2002-06-23 |
FROM | Ruben I Safir
|
SUBJECT | Re: [hangout] perl hash value
|
On 2002.06.23 11:33 Billy wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Fri, Jun 21, 2002 at 10:24:31AM -0400, Ruben Safir wrote: > > > > > > > > This is covered int he Perl Classes given by NYLXS which are > > inexpenssive. > > > > There is no such thing as an array of arrays. There is only > > an array of array references > > > > > > Something like this would work > > > > $myhash{ > > $reararyref1 => [$arrayref2 ,$arrayref3...] > > $reararyref2 => [$arrref4, arrayref5 ], > > $reararyref3 => [$arrref4, arrayref5 ], > > $reararyref4 => [$arrref4, arrayref5 ], > > $reararyref5 => [$arrref4, arrayref5 ], > > $reararyref6 => [$arrref4, arrayref5 ], > > $reararyref7 => [$arrref4, arrayref5 ], > > $reararyref8 => [$arrref4, arrayref5 ], > > } > > No it won't. You need to lose the $ in reararyref1,etc.
The $refarray1 will work (assuming it's defined as an array ref
> Also, this is better:
This is better but not what he asked for
> > my $array_of_arrays = [ > [00,01,02,03], > [10,11,12,13], > [20,21,22,23], > [30,31,32,33], > ]; > > > > > $arrayref = \-at-myarray; > > $arrayref2 = \-at-myarray; > > > > %hash = ($arrayref = > $arrayref2); > > > > or > > > > $hash[1][2] = value; > > Ruben, this surprisingly bad Perl code from you. > > Perl doesn't magically invent $hash[1] if you > try to assign to $hash[1][2].
No an array
$$hash{mykey}[0][0] = That magically creates a hash ref if he wants
> Also, $hash[1][2] doesn't mean anything. > If hash is a hash, then you have to use $hash{1} > to get at it.. If hash is a hashref, you have > to use $hash->{1} to get at it. > > If it's an array, use $hash[1], and calling > an array "-at-hash" isn't what I'd call good > programming practice. In any case, > what you've written here is noninstructive > to say the least. > > > - -- > "The funk, the whole funk, and nothing but the funk." > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.6 (GNU/Linux) > Comment: For info see http://www.gnupg.org > > iD8DBQE9Feos+2VvpwIZdF0RAhHjAJ46ARm3vjLfNnK3ft7TobRMy4uK9QCZAcjb > EOFWqa50sHcOoEj1gyqJwag= > =6qQ3 > -----END PGP SIGNATURE----- > -- __________________________
Brooklyn Linux Solutions __________________________ http://www.mrbrklyn.com - Consulting http://www.brooklynonline.com - For the love of Brooklyn http://www.nylxs.com - Leadership Development in Free Software http://www.nyfairuse.org - The foundation of Democracy http://www2.mrbrklyn.com/resources - Unpublished Archive or stories and articles from around the net http://www2.mrbrklyn.com/mp3/dr.mp3 - Imagine my surprise when I saw you... http://www2.mrbrklyn.com/downtown.html - See the New Downtown Brooklyn....
1-718-382-5752
____________________________ New Yorker Linux Users Scene Fair Use - because it's either fair use or useless....
|
|