my @list_var; if (ref $giant_hash{key} eq 'ARRAY') { for (@{ $giant_hash{key} }) { push @list_var, My::Class::Child->new( $_ ); } } else { push @list_var, My::Class::Child->new( $giant_hash{key} ); } #### our %giant_hash = Module->whatever(); sub _fill_lists { my ($thing, $thing_ref) = @_; my ($method , $flag); SWITCH: for ($thing) { /XXX/ && do { $method = \&My::Class::XXX->new; last; }; /YYY/ && do { $method = \&My::Class::YYY->new; last; }; /etc/ && do {$and_so_on; last; }; } if (ref $giant_hash{$thing} eq 'ARRAY') { for (@{ $giant_hash{$thing} }) { push @{ $thing_ref }, $method->( $_ ); } } else { push @{ $thing_ref }, $method->( $giant_hash{$thing} ); } } #### Can't use string ("XXX") as an ARRAY ref while "strict refs" in use at ./testme.pl line 76.