in reply to Data Structures Help

Well you probably want to read perlreftut but how about this:

my ($location, $h); while(<DATA>){ chomp; $location = $_ if m/^[a-zA-Z]/; next unless m/(\d+)\s+(\d+)/; $h->{$location}->{windows}++; $h->{$location}->{frames}->{"$1x$2"}++; $h->{$location}->{total_length}+= $1*2 + $2*2; } use Data::Dumper; print Dumper $h; my $fixed_cost_per_window = 100; my $cost_by_material = 0.5; my $total; for my $location( keys %$h ) { my $fixed = $h->{$location}->{windows} * $fixed_cost_per_window; my $materials = $h->{$location}->{total_length} * $cost_by_materia +l; printf "%-10s\t%d windows \$%7.2f\tmaterials \$%7.2f\ttotal \$%7.2 +f\n", $location, $h->{$location}->{windows}, $fixed, $materials, $fi +xed+$materials; $total += $fixed+$materials; } printf "\nTotal: \$%.2f\n", $total; __DATA__ office 1 120 120 120 120 140 135 155 135 120 120 bedroom 2 100 75 100 75 120 180

This produces:

$VAR1 = { 'bedroom 2' => { 'frames' => { '120x180' => '1', '100x75' => '2' }, 'windows' => '3', 'total_length' => '1300' }, 'office 1' => { 'frames' => { '155x135' => '1', '140x135' => '1', '120x120' => '3' }, 'windows' => '5', 'total_length' => '2570' } }; bedroom 2 3 windows $ 300.00 materials $ 650.00 total $ 950. +00 office 1 5 windows $ 500.00 materials $1285.00 total $1785. +00 Total: $2735.00

cheers

tachyon