Hi Chris, On Wed, Mar 28, 2012 at 12:02 PM, Chris Stinemetz <chrisstinem...@gmail.com>wrote:
> > > > It is always better to post a complete, short, working program rather > than a > > snippet. > > > > Maybe this will make it more clear as to what I am trying to > accomplish. I simply want to test to see if @hours exists as a second > key in the hash of hashes %data. > If it does not print \t otherwise print the value of the hash. > > Sorrry still trying to wrap my head around iterating through a nested > referenced hash. > > Thank you, > > Chris > > #!/usr/bin/perl > use warnings; > use strict; > use Data::Dumper; > > > > my %data =( > > '149' => { > '05' => '1', > '06' => '1', > '00' => '1', > '01' => '2', > '03' => '2', > '04' => '2' > }, > '077' => { > '05' => 'ND', > '06' => 'ND', > '00' => 'ND', > '01' => 'ND', > '02' => 'ND', > '04' => 'ND' > }, > '078' => { > '05' => '1', > '06' => '1', > '00' => '1', > '01' => '1', > '02' => '1', > '03' => '1', > }, > > ); > > my $href = \%data; > my @wanted = qw(077 078 149); > my @hours = qw(00 01 02 03 04 05 06); > > > foreach my $cell ( @wanted ) { > print "$cell:"; > foreach my $hr ( @hours ) { > foreach(keys %{$href->{$cell}}){ print "\t",$href->{$cell}{$_} if $_ == $hr; } } print "\n"; } *OUTPUT* 077: ND ND ND ND ND ND 078: 1 1 1 1 1 1 149: 1 2 2 2 1 1 > > output: > Use of uninitialized value in concatenation (.) or string at > ./example.pl line 46. > 077: ND ND ND ND ND ND > Use of uninitialized value in concatenation (.) or string at > ./example.pl line 46. > 078: 1 1 1 1 1 1 > Use of uninitialized value in concatenation (.) or string at > ./example.pl line 46. > 149: 1 2 2 2 1 1 > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Tim