in reply to Hash with sub

for my $file_name ( keys %{ $hash_name eq 'dat' ? \%dat_mapping : \%eng_mapping } ) { ... }
It would be more readable to break it up:
my $hash = $hash_name eq 'dat' ? \%dat_mapping : \%eng_mapping; for my $file_name (keys %$hash) { ... }

Replies are listed 'Best First'.
Re^2: Hash with sub
by ed_r (Initiate) on Mar 03, 2010 at 13:52 UTC
    Thanks so much for the help on the if/then/else statement, I was over thinking how to approach the problem.
    my $hash = $hash_name eq 'dat' ? \%dat_mapping : \%eng_mapping; for my $file_name (keys %$hash) {
    Works great, I did not realize you could put a hash ref in a scaler, so this was something new to me also. Tks again.