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

note

the long lines are quite unreadable. Use PerlTidy to clean up your source:

use Data::Dumper; use strict; use warnings; sub risk_eval { return { 'age_22' => 2, 'violations' => '1', 'age_18' => 2, 'dui' => '0', 'insured' => '1', 'major' => 0, 'tickets' => 0 }; } sub _build_risk_type { my ($self) = @_; my $E = risk_eval; my %E = %$E; warn ('risk criteria - ' . Data::Dumper::Dumper (\%E)); $E{age22} && $E{insured} && !$E{sr22} && !$E{dui} && ($E{tickets} <= 1) && !$E{major} and return 'prem'; $E{age18} && $E{insured} && !$E{sr22} && !$E{dui} && $E{tickets} < += 3 and return 'std'; $E{age18} and return 'substd'; die 'No useable risk type found.'; } _build_risk_type;

Oh, and making the return explicit in risk_eval doesn't hurt readability either.


True laziness is hard work