my %types; foreach my $type (map { "type$_" } qw(A B C D E)) { $types{$type} = $factory->new(type => $type, ...); }