LesleyB has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I'm working through the introductory DBI documentation and thought I'd try out a bit of code
foreach (@{ $DBI::EXPORT_TAGS{sql_types} }) { printf "%s=%d\n", $_, &{"DBI::$_"}; }
but it doesn't seem to work. It seems to pull up the sql_types tags but this code
#!/usr/bin/perl use strict; use warnings; use CGI; use DBI; use DBD::mysql; print "Content-Type: text/html\n\n"; foreach (@{ $DBI::EXPORT_TAGS{sql_types} }) { printf "%s=%d\n", $_, &{"DBI::$_"}; }
results in the error message
Content-Type: text/html Can't use string ("DBI::SQL_GUID") as a subroutine ref while "strict r +efs" in use at ./tmp.cgi line 12.
I can fix this by not using use strict; but I'd rather not. I have a Super Search on while "strict refs" in use to understand more about this error in general. However I usually fix/rewrite the code when I get this error. I'm just a bit stumped on how to get to the subroutine that returns the value of the sql_type
Is there a better way to achieve what this code sets out to do with use strict; in play?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strict refs
by Krambambuli (Curate) on Oct 28, 2008 at 09:13 UTC | |
by LesleyB (Friar) on Oct 28, 2008 at 09:35 UTC | |
|
Re: strict refs
by JavaFan (Canon) on Oct 28, 2008 at 10:52 UTC | |
by SuicideJunkie (Vicar) on Oct 28, 2008 at 14:01 UTC | |
by LesleyB (Friar) on Oct 28, 2008 at 15:36 UTC | |
by LesleyB (Friar) on Oct 28, 2008 at 15:31 UTC | |
by Narveson (Chaplain) on Oct 28, 2008 at 17:19 UTC |