use strict; use warnings; use 5.010; my @tests = ( [ # first testcase { # first step command => 'Launchapplication', params => [ qw/ executablepath dirpath / ], }, { # second step command => 'SelectMenu', }, # ... ], [ # second testcase { # first step command => 'Launchapplication', params => [ qw/ executablepath dirpath / ], }, { # second step command => 'Dothis', }, # ... ] ); my $package = "My::Package"; CASE: for my $ncase (0 .. $#tests) { my $case = $tests[$ncase]; foreach my $nstep (0 .. $#$case) { my $step = $case->[$nstep]; if(defined $step->{command}) { my $ok = 1; try { no strict 'refs'; "${package}::$step->{command}"->(@{ $step->{params} // [] }); } catch { warn sprintf("FAILURE test %d step %d failed, aborting", $ncase+1, $nstep+1); $ok = 0; # can't use "last" here due to try/catch limitation }; last CASE unless $ok; } else { warn sprintf("BUG: `command' undefined in test %d step %d", $ncase+1, $nstep+1); last CASE; } } }