http://qs1969.pair.com?node_id=790915


in reply to Dynamically Changing Packages w/out Eval

This doesn't avoid eval, but it shouldn't break syntax highlighting, nor postpone compile issues to runtime:
sub run_in_package (&$) { my($code, $package) = @_; eval "package $package; &$code; 1" or die $@; } foreach my $block ($self->get_blocks) { run_in_package { $block->setup->(); $block->code->(); $block->teardown->(); } $block->package; }