i always get confused doing this, but maybe this will at least inspire some
ideas. you can use pointers instead of looping through the hash again:
foreach $scheme_key (keys %scheme_hash) {
my (%temp) = calc_function($scheme_key);
$scheme{$scheme_key} = \%temp;
}
i tried before to do it skipping the %temp hash step, but that produces
strange results (like you get multiple copies of the same hash). getting
the values back is usually where i am confused, so here's the three possible
ways i think you can get them back:
# this would be nice - i don't know if it will work, though:
my ($value) = $scheme{$scheme_key}{'whatever'};
# or maybe:
my ($calc_hash) = $scheme{$scheme_key};
my ($value) = $calc_hash{'whatever'};
# or even:
my (%calc_hash) = %$scheme{$scheme_key};
my ($value) = $calc_hash{'whatever'};
maybe someone else on the list will see this and clear it up. also, i'm not
positive, but you might have to clean up by looping through all of the hash
pointers and undef them to avoid memory leak problems. anybody else try
this much???
best,
jason
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> [EMAIL PROTECTED]
> Sent: None
> To: [EMAIL PROTECTED]
> Subject: Perl-Win32-Web digest, Vol 1 #198 - 1 msg
>
>
> Send Perl-Win32-Web mailing list submissions to
> [EMAIL PROTECTED]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
> or, via email, send a message with subject or body 'help' to
> [EMAIL PROTECTED]
>
> You can reach the person managing the list at
> [EMAIL PROTECTED]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Perl-Win32-Web digest..."
>
>
> Today's Topics:
>
> 1. Hashes of Hashes / Hash slicing (C. James Hustler)
>
> --__--__--
>
> Message: 1
> From: "C. James Hustler" <[EMAIL PROTECTED]>
> To: "perl-win32-web@listserv1. ActiveState. com"
> <[EMAIL PROTECTED]>
> Subject: Hashes of Hashes / Hash slicing
> Date: Mon, 4 Dec 2000 13:37:58 -0000
>
> Greetings all
>
> I've got the hang of hashes of hashes and of hash slicing but not getting
> the two to work together!
>
> I've got a function which calculates and returns a small hash of data.
> I need to run the function several times for different schemes and then
> compare the results at the end.
> Is there an easier way of collating the data in the HoH other than
>
> foreach $scheme_key (keys %scheme_hash) {
>
> my %calc_hash = calc_function($scheme_key)
>
> foreach (keys %calc_hash) {
> $scheme{$scheme_key}{$_} = $calc_hash{$_};
> }
>
> }
>
> Many thanks in advance
>
> James
>
>
>
>
> --__--__--
>
> _______________________________________________
> Perl-Win32-Web mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
>
>
> End of Perl-Win32-Web Digest
>
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web