http://www.perlmonks.org?node_id=913427


in reply to Storing an indeterminate number of hash keys in a variable

It'd be easier if you just stored the list of keys in an array ref instead of a string

However, you could just parse the keys and traverse the data structure to find the proper value like so:

use strict; use warnings; my @array = ( '{title}', '{Rule}{Severity}', '{Rule}{weight}', '{Rule}{id}', '{Rule}{version}', '{Rule}{title}', '{Rule}{detailedDescription}{VulnDiscussion}', '{Rule}{detailedDescription}{Responsibility}', '{Rule}{detailedDescription}{IAControls}', '{Rule}{check}{check-content}', '{Rule}{fixtext}{content}', ); for my $firstKey (sort keys %hashData) { for my $arrayKey (@array) { my $val = $hashData{$firstKey}; # Traverse to desired value $val = $val{$1} while $arrayKey =~ /\{(.*?)\}/g; print $val, "\n"; } }