First of all, let me commend you for being concerned with
your data structures. Good data structures can make a
program much simpler to understand and extend.
Anyway, I'd be inclined to do something like this:
my @clusters = (
{
Name => 'cluster1',
Workers => [ qw(h1 h2 h3 h4 h5 h6) ],
Queen => 'h7'
},
{
...
}
);
foreach my $cluster (@clusters) {
foreach my $worker (@{$cluster->{Workers}}) {
handle_worker($worker, ...);
}
handle_queen($cluster->{Queen}, ...);
}
This is obviously very abstract. If you want to do all the
workers in parallel you could. I also don't know if "workers"
and "queen" correctly describes the relationship between these
servers; you could probably think of better terms.
But this kind of arrangement gives you a lot of flexibility.
For example, if another kind of server gets added to the
mix later, it's trivial to add processing for it.