in reply to No strict refs
use strict 'refs'; is what's preventing simulate_opening_file from being called if someone did <simulate_opening_file>...</>, so I applaud your desire to use it.
Two options:
Keep using no strict 'refs';, but require that the callbacks are located in a specific patckage that contains nothing but callbacks.
1 while s/<([^<]+?)>([^<]*?)<\/>/ $_{$1}->{$2} ||= do { #TODO: Make sure $1 doesn't contains "::". my $func = $pkg . "::" . $1; #TODO: Make sure $func exists. no strict 'refs'; $func->($2) } /e;
Require that callbacks get registered.
my %cb = ( use => \&use, dbl => \&dbl, ); 1 while s/<([^<]+?)>([^<]*?)<\/>/ #TODO: Make sure $cb->{$1} exists. $_{$1}->{$2} ||= $cb->{$1}->($2) /e;
By the way, you'll have problems if the replacement value contains a "<".
|
|---|