eval()

T

toylet

eval ( $dbh->do("DROP TABLE foo") );
print "dropped table foo\n" if $@;

The program execution stopped at eval(). ISn't it supposed to ignore errors?
 
T

toylet

toylet said:
eval ( $dbh->do("DROP TABLE foo") );
print "dropped table foo\n" if $@;

The program execution stopped at eval(). ISn't it supposed to ignore errors?
here are the errors:

DBD::mysqlPP::db do failed: Unknown table 'foo' at ./mysql.pl line 15.
DBD::mysqlPP::db do failed: Unknown table 'foo' at ./mysql.pl line 15.
 
B

Brian McCauley

toylet said:
eval ( $dbh->do("DROP TABLE foo") );
print "dropped table foo\n" if $@;

The program execution stopped at eval(). ISn't it supposed to ignore errors?

You want eval{} not eval(). They do quite different things. BTW: For
what you are doing you don't need to know what eval() does but if
you are curious RTFM.

BTW: It would be more conventional to print "dropped table foo" if the
operation had _not_ failed.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 
T

toylet

You want eval{} not eval(). They do quite different things. BTW: For
what you are doing you don't need to know what eval() does but if

Program execution now continued, but the error message still showed up.
COuld I suppress that as well?

DBD::mysqlPP::db do failed: Unknown table 'foo' at ./mysql.pl line 14.
 
G

gnari

toylet said:
Program execution now continued, but the error message still showed up.
COuld I suppress that as well?

DBD::mysqlPP::db do failed: Unknown table 'foo' at ./mysql.pl line 14.
DBI docs

gnari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,833
Members
47,380
Latest member
AlinaBlevi

Latest Threads

Top