Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I thought I understood eval, but... I may have been mistaken. I am trying to use eval with DBI, and I ran into an error with statements like:
eval {$sth->execute($value) } if ($@) { print "Error\n"; }
And in fact, I was able to extract this down to the ridiculously simple case:
eval {1} if (1) {}
Something like this can't be a bug, I figure, so it must be my understanding of eval is mistaken. Can anybody shed some light on what's going on?
Incidentally, the error message itself isn't too helpful:
syntax error at testseqio.pl line 2, near ") {"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Syntax error with if following eval
by liz (Monsignor) on Sep 08, 2003 at 21:14 UTC | |
by Anonymous Monk on Sep 08, 2003 at 21:28 UTC | |
by liz (Monsignor) on Sep 08, 2003 at 21:47 UTC | |
by simonm (Vicar) on Sep 09, 2003 at 03:31 UTC | |
by benizi (Hermit) on Sep 09, 2003 at 19:21 UTC | |
by Anonymous Monk on Sep 09, 2003 at 00:04 UTC |