#!/usr/bin/perl # Load data inside %times hash my %times; while () { next unless /\S/; # just in case... my ($month, $weeknum, $day, $val) = split /;/; $times{$month}{"wk$weeknum"}{$day} = $val; } # ... all your program here ... __DATA__ May;1;Mon;24.50 May;1;Tues;23.40 May;1;Wed;22.40 May;1;Thu;25.01 May;1;Fri;24.10 ... and so on...