use strict; use warnings; use Data::Dumper; my %foodata = ( 'foo1' => { thirdpart => 229, size => 3 }, 'foo2' => { thirdpart => 218, size => 7 } ); foreach my $foo qw( foo1 foo2 ) { my @act_bsites = map { join( ' - ', $_, 201, $foodata{$foo}{thirdpart} ) } 1 .. $foodata{$foo}{size}; print Dumper( \@act_bsites ); }