princepawn has asked for the wisdom of the Perl Monks concerning the following question:
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 $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to convert a symbolic reference to a hard reference
by broquaint (Abbot) on Nov 06, 2003 at 00:19 UTC | |
|
Re: How to convert a symbolic reference to a hard reference
by blokhead (Monsignor) on Nov 06, 2003 at 00:18 UTC | |
|
Re: How to convert a symbolic reference to a hard reference
by revdiablo (Prior) on Nov 06, 2003 at 00:47 UTC | |
by ysth (Canon) on Nov 06, 2003 at 03:24 UTC | |
|
Re: How to convert a symbolic reference to a hard reference
by ysth (Canon) on Nov 06, 2003 at 00:26 UTC | |
|
Re: How to convert a symbolic reference to a hard reference
by Roger (Parson) on Nov 06, 2003 at 00:28 UTC | |
|
Re: How to convert a symbolic reference to a hard reference
by Anonymous Monk on Nov 06, 2003 at 14:28 UTC |