#!/usr/bin/perl use warnings; use strict; my @month = qw/JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC/; my $hash = { 2 => { W1 => 10.14, W2 => 11.22, }, 3 => { W1 => 33.17, W2 => 44.44, }, 4 => { W1 => 55.00, W2 => 66.66, }, }; my $lim = { 2 => { W1 => { L => 11, U => 14 }, W2 => { L => 13, }, }, 4 => { W2 => { L => 13.02, U => 15 }, }, }; for my $month ( sort keys %$hash ) { print "$month[$month-1]:\n"; for my $week ( sort keys %{$hash->{$month}} ) { my $lower = defined $lim->{$month}->{$week}->{L} ? $lim->{$month}->{$week}->{L} : 0; # min value my $upper = defined $lim->{$month}->{$week}->{U} ? $lim->{$month}->{$week}->{U} : 999; # max value my $value = $hash->{$month}->{$week}; my $below = ($value < $lower) ? sprintf('%6.2f', $value) : ''; my $above = ($value > $upper) ? sprintf('%6.2f', $value) : ''; my $in = ($value >= $lower and $value <= $upper) ? sprintf('%6.2f', $value) : ''; printf " %s %6.6s <%6.2f> %6.6s <%6.2f> %6.6s\n", $week, $below, $lower, $in, $upper, $above; } }