in reply to RE: Re: Silencing the grumbling from DBD::ODBC
in thread Silencing the grumbling from DBD::ODBC

They are equivalent. Consider:
$a = $b = 0; eval { $a = 3; }; $b = eval { 3; }; print "$a, $b\n"; # 3, 3
Eval operates in the same context as any other code. The return from eval is the return value of whatever that eval did. The only difference is that eval blocks can't die; errors are stored in $@ and execution of the eval block stops.

Replies are listed 'Best First'.
RE: RE: RE: Re: Silencing the grumbling from DBD::ODBC
by little (Curate) on Sep 28, 2000 at 19:45 UTC
    $a = 'die "whohoo";'; $b = 3; print "mmh".eval($a)."?"; print "mmh".eval($b)."?";
    Have a nice day
    All decision is left to your taste
      Perhaps I'm missing something, but shouldn't the returned value here be undefined? He's testing $ret. If the eval failed (died, whatever), $ret should be undefined. His test should work.

      I think the problem though is that the eval isn't dying. It's just warning. $ret thus is set to the return of whatever the fetch method he used. If his eval died, we shouldn't see an error message at all, it should go into $@.

      Sorry if I'm missing something or if we're talking about two slightly different things.

        No,
        cause the result of the query is the warning, which is a string, so the eval gives back a string and does not die, cause it has not interpreted the query but the query result.
        Have a nice day
        All decision is left to your taste