in reply to printing true false values

print "IP Validity Status:". ( validate_ip_addr( $ip ) ? 1 : 0 )."\n";

We're not surrounded, we're in a target-rich environment!

Replies are listed 'Best First'.
Re^2: printing true false values
by HarshaHegde (Sexton) on Dec 30, 2007 at 16:15 UTC
    Thanks Jason and FunkyMonk, for the quick response. I did think of doing something similar: using the if else. However, by the definition of truth values in perl, 0 represents false and anything else represents true. So, if a boolean expression evaluates to true, it will return a 1 and if it evaluates to false, shouldn't it return a 0?
      perlsyn.pod says:
      Truth and Falsehood
      The number 0, the strings ’0’ and ’’, the empty list "()", and "undef" are all false in a boolean context. All other values are true. Negation of a true value by "!" or "not" returns a special false value. When evaluated as a string it is treated as ’’, but as a number, it is treated as 0.
      What values are considered true and false is not the same thing as what an expression evaluates to. Many Perl operators that evaluate to a boolean evaluate to 1 when true and '' (the empty string) when false.
      you could force numerical context