Is there anyway to refactor this so that it does not need the no strict 'refs', and can work under Modern::Perl without it?
use Modern::Perl;$_=' <use><qd>action</></> <use><qd>action</></> '; $_{'s'} = { jeopardy =>"21"}; $_{'qd'} = { action => 'default' }; sub dbl { say "this should only calc once"; $_{'dbl'}->{$_[0]} = $_[0]*2; } sub use { $_{'use'}->{$_[0]} = &simulate_opening_file; } sub simulate_opening_file { say "this should only slurp once"; "The answer is <dbl><s>jeopardy</></>" }; while (/<([^<]+?)>([^<]*?)<\/>/) { my $l=$+[0]-$-[0]; no strict 'refs'; my $r = $_{$1}->{$2} ||= $1->($2); substr($_,$-[0],$l,$r); } say;
In reply to No strict refs by Logicus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |