in reply to Re^2: multi level hash terror - if statement to access specific elements
in thread multi level hash terror - if statement to access specific elements
Thanks but that still prints out the entire hash instead of just the last name of "Gay"
So you want to fix this?
for my $key ( keys %names ) { for my $key2 ( keys $names{$key} ) { print "First Name:" . $names{$key}{$key2}[0], "\n"; if ( $names{$key}{$key2}[0] = 'Gay' ) { print "Last Name:" . $names{$key}{$key2}[1] . "\n"; } } }
You want to only print when last name is Gay?
Its simple, get rid of the other print statement
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: multi level hash terror - if statement to access specific elements
by hungrysumo79 (Initiate) on Feb 13, 2016 at 04:01 UTC | |
by beech (Parson) on Feb 13, 2016 at 04:08 UTC | |
by hungrysumo79 (Initiate) on Feb 13, 2016 at 04:45 UTC | |
by beech (Parson) on Feb 13, 2016 at 07:56 UTC | |
by soonix (Chancellor) on Feb 17, 2016 at 10:52 UTC |