Ah yes, I forgot about redo. But your second approach introduces another block and thus won't work:
my %handler = ( hello => sub() { print "hello world\n" }, ); my ($ok,$err); my @handlers = keys %handler; my $cfg_str = 'hello();'; { no strict 'refs'; # We don't want to introduce another scope, as that will # negate the effect of the local: NEXT: { my $n = shift @handlers; local *{$n} = $handler{ $n }; redo NEXT if @handlers; } $ok = eval $cfg_str; $err = $@; } warn $err if $err; __END__ Undefined subroutine &main::hello called at (eval 1) line 1.
In reply to Re^2: A useful use of goto
by Corion
in thread A useful use of goto
by Corion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |