Outout:use strict; my %house; my $room; while (<DATA>) { chomp; next unless $_; # skip blank lines if(/^\D/) { $room = $_ } else { $house{$room}{$_}++ } } foreach my $room (keys %house) { print "$room:\n"; print "width height quantity\n"; map { print "$_ $house{$room}{$_}\n"; } sort { $house{$room}{$b} <=> $house{$room}{$a} } keys %{$house{$room}}; } __DATA__ office 1 120 120 120 120 140 135 155 135 120 120 bedroom 2 100 75 100 75 120 180
bedroom 2: width height quantity 100 75 2 120 180 1 office 1: width height quantity 120 120 3 140 135 1 155 135 1
In reply to Re: Data Structures Help
by Arunbear
in thread Data Structures Help
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |