DBI does not accept symbolic references for its HandleError attribute and that is what this string is intended to handle.
Therefore, I must give DBI a hard reference and would like to know the most direct way of doing so. Below almost works, but I get a funny error message in my dummy example.
*Config::DBI::error_handler = eval "&$symbolic_ref"; DBI->connect($DSN, $User, $Pass, { HandleError => Config::DBI::error_handler } );
package M; sub x { print "sub __PACKAGE__x"; } sub y { print "sub __PACKAGE__y"; } 1; package N; $s = 'M::y'; *M::x = eval "&$s"; M::x();
but it gives a bizarre errmsg:
~/hacks/config-dbi/scripts $ perl symref.pl Undefined subroutine &main::1 called at symref.pl line 19. sub __PACKAGE__y ~/hacks/config-dbi/scripts $
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |