my $months = $dbh->selectall_arrayref("select to_char(last_day(add_months('14-May-2004', (rownum-1))),'MON-RRRR') dt from all_objects where rownum <= months_between(sysdate,'31-May-2004')+1"); my $month; my %monthhash; my $x = 0; foreach $month (@$months) { $monthhash{@$month[0]} = 0; print "check $monthhash{@$month[0]} @$month[0] @{$months->[$x]} ** $monthhash{ (@{$months->[$x]}) }\n"; $x++; } #### May 04 Jun 04 Jul 04 Aug 04 Sep 04 Oct 04 50 100 110 May 04 Jun 04 Jul 04 Aug 04 Sep 04 Oct 04 50 50 50 100 110 110