Option 1)
You could build an iterator, seperating the traversal from the client as demonstrated by the following:
{
my $iter = get_target_iter($stuff);
while (my (
$env_name,
$platform_name,
$host_name,
$target_name,
$total_capacity,
$free_capacity,
) = $iter->()) {
local $, = "\t";
local $\ = "\n";
print $env_name,
$platform_name,
$host_name,
$target_name,
$total_capacity,
$free_capacity;
}
}
Tested.
Update: Below is an alternative iterator. It's a drop-in replacement for the above function. This version is much smaller thanks to Algorithm::Loops's NestedLoops.
Tested. |