> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf
> Of Gregory Bair
> Sent: Monday, May 29, 2000 9:01 AM
> To: Perl-Win32-Users Mailing List
> Subject: Arrays and Hashes
>
>
> Can a hash be the value of an array element? specifically, what would be
> the syntax for defining values and referencing them. What comes
> to mind is
> something like $array[1]{hashkey} = hashvalue, though this seems silly to
That was close. Here are some statements to help you out
my @arr = ();
push @arr, {}; # push an empty hashref onto the array
my $href = $arr[0]; #copy the reference
$href->{foo} = 'bar';
print ${$arr[0]}{foo}; #same as previous line
print $arr[0]->{foo}; #same again
$arr[0]->{baz} = 'swing it';
print $href->{baz};
for (keys %{$arr[0]}) { print "$_\n" }
for $href(@arr)
{
for $key(keys %{$href}) { printf "%s\t%s\n", $key, $href{$key}}
}
Take a look at the perlref and perlreftut pages of the docs. If you
have activestate installed with the defaults start at
c:\perl\html\index.html
hth,
--
robert friberg, ensofus ab
+46(0)708 98 57 01
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]