# create some dummy subroutines sub test_A { } sub test_B { } # redefine them as real subs if the conditions # are right local *test_A = sub { my $x = shift; # perform test A on $x using data from %data_h # if it fails, add an error message and go on to # the next list item } if $condition{'a'} == 1; local *test_b = sub { my $x = shift; # perform test B on $x using data from %data_h # if it fails, add an error message and go on to # the next list item } if $condition{'b'} == 1; sub do_tests { my $to_test = shift; # depending on what is in the %condition hash, # these will either be a real subroutine or just a dummy test_A($to_test); test_B($to_test); } foreach (@list) { do_tests($_); push @passed, $_; }