http://qs321.pair.com?node_id=624248

hacker has asked for the wisdom of the Perl Monks concerning the following question:

Thanks to the patient mentoring of Anno, bart, and clinton, I'm making this post to embiggen my Perl skills.

I've got a project that I'm building to mirror an enormous amount of data in several dozen languages. Right now I have 3 separate arrays:

my @langs = ('en', 'de', 'fr', 'it', 'gr', '...'); my @projects = ('dogs', 'cats', 'birds', 'horses'); my @targets = ('images', 'data', 'links', 'other');
In each of these languages, I build a structure that looks like:
endogs, encats, enbirds, enhorses dedogs, decats, debirds, dehorses frdogs, frcats, frbirds, frhorses itdogs, itcats, itbirds, ithorses grdogs, grcats, grbirds, grhorses
Within each of those projects, I fetch the data for them:
endogs/images.tar.bz2 endogs/data.tar.bz2 endogs/links.tar.bz2 endogs/other.tar.bz2 dedogs/images.tar.bz2 dedogs/data.tar.bz2 dedogs/links.tar.bz2 dedogs/other.tar.bz2 [...] encats/images.tar.bz2 encats/data.tar.bz2 encats/links.tar.bz2 encats/other.tar.bz2 decats/images.tar.bz2 decats/data.tar.bz2 decats/links.tar.bz2 decats/other.tar.bz2
The way I'm doing this is very "array-based":
foreach my $lang (@langs) { foreach my $project (@projects) { mkpath ("$project/$lang"); foreach my $target (@targets) { my $backup = $backup_file; my $output = $output_save_file; print "Mirroring $project ($lang) now...\n"; # Other stuff happens here } } }

I've always had trouble grokking hashes in Perl, many people know that... but it looks like I have to bite the bullet here and dive into an HoHoA to create this structure.

My question is... can I create a "completely anonymous hash", which can be built dynamically from the values in each of the arrays above? I'd actually like to add more granular detail here, without adding more and more arrays (further increasing that nesting)... something like:

'it' => 'Italian' { ... }, 'es' => 'Spanish' { ... }, ...

The goal is to be able to fetch each of the @targets within each of the @projects, for each @lang supported. If I want to back up another set of targets in another language, I should just be able to add another language to the list and have it inherit the rest of the members of the "anonymous hash" (if I'm using the vernacular correctly).

Is this possible? Is there another way to represent this structure without more levels of array nesting, and without duplicating manually-typed entries in a growing sub?