Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Just another Perl shrine
 
PerlMonks  

Re: What is truth? (Curiosity corner)

by Anonymous Monk
on Dec 20, 2001 at 20:17 UTC ( [id://133616]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to What is truth? (Curiosity corner)

What about "0E0" for zero-but-true? Doesn't it work the same way?
perl -wle 'print 23+"0E0" if "0E0"' 23

Replies are listed 'Best First'.
Re: Re: What is truth? (Curiosity corner)
by robin (Chaplain) on Dec 21, 2001 at 02:24 UTC
    Yeah, it does indeed. I'm not quite sure why "0 but true" is often preferred. Maybe because it's more explicit about its intention?
      "0E0" is used by the DBI (and DBD's) for eg. $sth->execute when the SQL-statement processed 0 rows but did not error.

      This allows constructions like my $rows=$sth->execute or die "SQL error" ( Of course this would be expressed better using $dbh->{RaiseError} = 1).

      The relevant part of the DBI documentation states:

      For a non-`SELECT' statement, `execute' returns the number of rows affected, if known. If no rows were affected, then `execute' returns "`0E0'", which Perl will treat as 0 but will regard as true. Note that it is not an error for no rows to be affected by a statement. If the number of rows affected is not known, then `execute' returns -1.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://133616]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.