in reply to strict refs usage
dominus has three excellent articles on why "it's stupid to use a variable as a variable name".
My personal preference (and this can be done in just about any context that uses symblic refs) is to use a hash table instead. In your case, it would be something like:
This is untested, but variations are of course possible.my @tests = ( { name => 'test1', code => sub { print "this is test 1\n"; }, }, { name => 'test2', code => sub { print "this is test 2\n"; }, }, ); for my $t (@tests) { print "Test $t->{name} is currently running\n"; $t->{code}(); }
|
|---|