in reply to Data Structures Help

You can't use a straight hash of hashes because he seems to want the original order of office 1, bedroom 2, etc. preserved, and a hash won't do that. You also have to provide for there being empty lines.
use strict; use warnings; my (@arr, $ref); while (<DATA>) { chomp; if (/^[a-zA-Z]/) { $arr[$#arr+1][0] = $_; } elsif (/^\d/) { $arr[$#arr][1]{$_}++; } } foreach (@arr) { print @$_[0] . "\n\n"; print "width height quantity\n\n"; $ref = @$_[1]; for (sort {$ref->{$b} <=> $ref->{$a} or $a cmp $b} keys %$ref) { print "$_ " . $ref->{$_} . "\n\n"; } } __DATA__ office 1 120 120 120 120 140 135 155 135 120 120 bedroom 2 100 75 100 75 120 180