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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Dynamically Changing Packages w/out Eval
by betterworld (Curate) on Aug 25, 2009 at 12:11 UTC |
In Section
Seekers of Perl Wisdom