%goodhash = ( red => '1', blue => '2', green => '3', ); @colors = qw(red blue green); print $fh join("|", @hash{@colors}), "\n" #### $evilhash{$id} = { red => '1', blue => '2', green => '3', }; @colors = qw(red blue green); #### print $fh join("|", @evilhash{$id}{@colors}), "\n" or this @{$evilhash{$id}}{@colors}