in reply to boolean chaining - && and 'and'

$E{age22} isn't true.

When staring at it doesn't help, you can construct something like this:

print( $E{age22} ?1:0,"\n"); print( $E{insured} ?1:0,"\n"); print( !$E{sr22} ?1:0,"\n"); print( !$E{dui} ?1:0,"\n"); print( ($E{tickets} <= 1) ?1:0,"\n"); print( !$E{major} ?1:0,"\n");

Make sure to copy the expressions exactly. Don't retype them.

Update: I forgot to mention.

my $E = risk_eval; my %E = %$E;

can be written as

my %E = %{ risk_eval() };

but most people would just work with the reference instead of copying the hash.

Replies are listed 'Best First'.
Re^2: boolean chaining - && and 'and'
by moritz (Cardinal) on Jul 29, 2009 at 14:52 UTC
    When staring at it doesn't help,

    ... you look out for other tools. What I found very helpful is to place the cursor over an identifier (really any identifier where I expect trouble) and press the * or # key.

    That's the vim command to search for the current identifier as a word, and since I have the option hlsearch enabled, I automatically see all occurrences of this identifier on the current page, and usually I notice if one is missing.

    That's very handy for example to spot typos in package names or hash keys, both of which aren't checked to the same amount at compile time as variables are (assuming you use strict).