use Template::Alloy; my $t = Template::Alloy->new( V1DOLLAR => 1, UNDEFINED_ANY => sub { die "Undefined variable\n" }); local $t->{'_vars'} = $vars; foreach my $name (keys %$funcs) { $t->define_vmethod('TEXT', $name, $funcs->{$name}) } # and later # inside the test forloop local pos($test->[0]) = 0; my $state2 = eval { $t->play_expr($t->parse_expr(\$test->[0])) }; $state2 = [] if ! defined $state2; @return = UNIVERSAL::isa($state2, 'ARRAY') ? @$state2 : ($state2); eval { die if @expect != @return; for ( my $j = 0; $j < @expect; $j++ ) { die if $expect[$j] ne $return[$j]; } }; # and later for the errors test local pos($test->[0]) = 0; eval { $t->play_expr($t->parse_expr(\ $test->[0])); die "Didn't match\n" if pos($test->[0]) != length($test->[0]) }; my $alloy_error = $@ ? do { my $e = $@; chomp($e); "Success ($e)" } : 'No alloy error';