in reply to hashes with multiple keys

How can I parse through this?

There are many ways you could parse your file. Here is one way:

#!/usr/bin/perl use strict; use warnings; my $section = "unknown"; my %volumes; # volumes for each host, keyed by host name my %capacities; # capacity of each volume, keyed by volume name while(my $line = <DATA>) { chomp($line); if ( $line =~ m/^host_output$/) { $section = "host_output"; my $discard = <DATA>; # discard the header line } elsif ( $line =~ m/^volume_output$/) { $section = "volume_output"; my $discard = <DATA>; # discard the header line } elsif ( $line =~ m/^$/) { $section = "unknown"; } elsif ($section eq "host_output") { my ($volume, $host) = split(/\s+/,$line); push(@{$volumes{$host}}, $volume); } elsif ( $section eq "volume_output" ) { my ($volume, $capacity) = split(/\s+/,$line); $capacities{$volume} = $capacity; } } foreach my $host (sort keys %volumes) { foreach my $volume (@{$volumes{$host}}) { print "$host: $volume: $capacities{$volume}\n"; } } __DATA__ host_output volume_name host_name vol1 host1 vol2 host1 vol3 host1 vol4 host2 vol5 host2 vol2 host2 volume_output volume_name size vol1 10g vol2 20g vol3 30g vol4 30g vol5 20g

Which produces:

host1: vol1: 10g host1: vol2: 20g host1: vol3: 30g host2: vol4: 30g host2: vol5: 20g host2: vol2: 20g

This example makes several assumptions about your data, which you should consider carefully.

Update: removed extraneous "next;"