my %months = (
FEB => { W1 => 11.14,
W2 => 11.22, },
MAR => { W1 => 33.17,
W2 => 44.44, },
APR => { W1 => 55.00,
W2 => 66.66, },
);
my %limits = (
FEB => { W1 => { L1 => 11, U1 => 12.05 },
W2 => { L1 => 13.06, U1 => 13.06 }, },
APR => { W1 => { L1 => 1, U1 => 20 },
W2 => { L1 => 33, U1 => 13.02 }, },
MAR => { W1 => { L1 => -12.05, U1 => -14.0 },
W2 => { L1 => 22.0, U1 => -13.02 }, },
);
####
for my $mon ( sort keys %months ) {
for my $week ( sort keys %{ $months{$mon} } ) {
if ( exists $limits{$mon} && exists $limits{$mon}{$week} ) {
my $value = $months{$mon}{$week};
my $upper = $limits{$mon}{$week}{U1};
my $lower = $limits{$mon}{$week}{L1};
printf "%6.2f <= %6.2f <= %6.2f - ",
$lower, $value, $upper;
if ( $value >= $lower && $value <= $upper ) {
print "OK\n";
}
else {
print "NOT ok\n";
}
}
else { warn "No limits for month $mon / week $week\n" }
}
}
####
1.00 <= 55.00 <= 20.00 - NOT ok
33.00 <= 66.66 <= 13.02 - NOT ok
11.00 <= 11.14 <= 12.05 - OK
13.06 <= 11.22 <= 13.06 - NOT ok
-12.05 <= 33.17 <= -14.00 - NOT ok
22.00 <= 44.44 <= -13.02 - NOT ok