Capacio, Paula J wrote:
Replace
>> print "\nTest iterating over the 3 dimensional hash of hashes...\n";
>> foreach my $fileTypeKey (keys %tp3Lookup) {
>> print "$fileTypeKey => \n";
>> foreach my $tpKey (keys %{$tp3Lookup{$fileTypeKey}}
my $anon_ref = \%{ $tp3Lookup{$fileTypeKey}->{$tpKey} };
and use that in the now, slightly saner for loop:
foreach my $anonKey ( keys %{ $anon_ref } ) {
i.e.
print "\nTest iterating over the 3 dimensional hash of hashes...\n";
foreach my $fileTypeKey (keys %tp3Lo
t a 3 dimensional one.
Thanks in advance,
Paula
Here's the scriptlet: watch out for line wraps...
use strict;
#2 Dimensional Hash of hashes
my %tp2Lookup =(
'MNTHLY' => { #anonymous hash
'LIFEPLANS' => 'M_L_value'
PROTECTED]
Subject: RE: hash of hashes-- preserve insertion order
Isn't it as easy as creating a separate @array that you push the keys into
as you build the hashes?
-Original Message-
From: James S. Martin [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 17, 2003 10:46 AM
To: [EM
Isn't it as easy as creating a separate @array that you push the keys into
as you build the hashes?
-Original Message-
From: James S. Martin [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 17, 2003 10:46 AM
To: [EMAIL PROTECTED]
Subject: hash of hashes-- preserve insertion orde
James S. Martin wrote:
I have a multi-level hash (about 4 hashes deep) and I want to keep the
insertion order of the keys in which it was created. I've tried use
Tie::IxHash but it doesn't seem to handle the keys in the sub-hashes. Is
there a better way to do this?
Thanks,
{[DuhSNIP]}
Sorr
James S. Martin wrote:
I have a multi-level hash (about 4 hashes deep) and I want to keep the
insertion order of the keys in which it was created. I've tried use
Tie::IxHash but it doesn't seem to handle the keys in the sub-hashes. Is
there a better way to do this?
[snip]
I've put an arra
I have a multi-level hash (about 4 hashes deep) and I want to keep the
insertion order of the keys in which it was created. I've tried use
Tie::IxHash but it doesn't seem to handle the keys in the sub-hashes.
Is there a better way to do this?
Thanks,
James
___
Title: hash of hashes -- odd behavior
Peter,
On the line:
foreach my $bucket (sort {$a <=> $b} keys
%{$mttr_total{$abrv_grp}} )
You have the
variable “$abrv_grp” but on the previous foreach you use the variable $group. If
you change $abrv_grp to $group it shoul
Title: RE: hash of hashes -- odd behavior
That was it!!! I am using $group as a whole name and $abrv_grp as an
abbreviation of $group. Sometimes its not the data that's convoluted, its the
programmer. Thanks for the keen eye. Curious that this worked at
all.
-Original Me
Title: RE: hash of hashes -- odd behavior
I should say, I have also printed a debug line when this bit of data is added to the hash of hashes too, and it is there.
-Original Message-
From: Peter Eisengrein [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 30, 2002 12:06
To: Perl
Title: hash of hashes -- odd behavior
I have a hash of hashes that, at first pass, appears to be missing expected data when I try to get it via variables. However, if I call it directly (see $mttr_total{'TAC'}{'2'} in debug line below) I get the data. What gives?
Th
[EMAIL PROTECTED] wrote:
> $Bill got your $ vs \% problem, but just FYI. In general it is not safe
> to store a list of references from DBI methods, many (soon to be all) of
> them recycle the ref, so you could end up with an array or hash of
> identical refs.
So store a copy of the data referen
> Thanks for the reply. I have included the result set and some more of
the
> code. Your help is appreciated.
>
>
> my $dbh = DBI->connect("DBI:XBase:C:/Perl/progs/customer") or die
> $DBI::errstr;
> my $sth = $dbh->prepare("select ID, First_Name from customer") or die
> $dbh->errstr();
>
At 09:03 07/05/2002 +0100, Simon Oliver wrote:
>Lee Goddard wrote:
> > $i_ama_hash_ref->{ima_key2}->{"I'm a value")="I'm a key";
>
>You swapped a brace with a bracket and didn't you mean this anyway:
>
>$i_ama_hash_ref->{ima_key2}->{"I'm a key"}="I'm a value";
Sure did. That'll teach me to try an
Lee Goddard wrote:
> $i_ama_hash_ref->{ima_key2}->{"I'm a value")="I'm a key";
You swapped a brace with a bracket and didn't you mean this anyway:
$i_ama_hash_ref->{ima_key2}->{"I'm a key"}="I'm a value";
and don't forget, when it get's multidimensional you can drop the ->
notation so it looks
At 22:17 06/05/2002 -0700, Kevin wrote:
>I am reading a DBI record into a hash reference - my $row =
>$sth->fetchrow_hashref() - I would like to create a hash to hold all of the
>returned rows (or thus, hashes) with the ID being the key, so for example
>
>$returned_rows{$row->{'ID'}} = $row
$I_am
Kevin wrote:
>
> Thanks for the reply. I have included the result set and some more of the
> code. Your help is appreciated.
>
>
> my $dbh = DBI->connect("DBI:XBase:C:/Perl/progs/customer") or die
> $DBI::errstr;
> my $sth = $dbh->prepare("select ID, First_Name from customer") or die
> $dbh->er
reference - my $row =
> > $sth->fetchrow_hashref() - I would like to create a hash to hold all of
the
> > returned rows (or thus, hashes) with the ID being the key, so for
example
> >
> > $returned_rows{$row->{'ID'}} = $row
> >
> > Essentially I wou
Thanks Ron, I've tried your recommendation on another piece of test
code and it works the way I want. I guess the autovivication thing in
this context can be regarded as just another Perl feature, for now at
least.
Regards,
Ian.
>From: "Ron" <[EMAIL PROTECTED]>
>
{'Key3'} ) {...}
>From the docs:
"This surprising autovivification in what does not at first--or even
second--glance appear to be an lvalue context may be fixed in a future
release."
- Original Message -
From: "Ian Taite" <[EMAIL PROTECT
> -Original Message-
> From: bruno stefanutti [mailto:[EMAIL PROTECTED]]
> Sent: 31 October 2000 14:19
> To: '[EMAIL PROTECTED]'
> Subject: hash of..hashes...
See this excellent article, "Understand References Today - © Copyright 1998
The Perl Journal.&q
What
you describe there is a list of hashes
my
@mother=();
$mother[1]=%hash
$mother[2]=%hash2
however a hash of hashes is possible.
%hash1=(name=>'fred');
%hash2=(name=>'bill');
%mother_of_hashes=();
$mother_of_hashes{myhash}=%hash1;
$mother_of_hashe
23 matches
Mail list logo