use strict; use Data::Dumper; my %hash; my $header_info; DAT: while () { next if !length($_); # ignore empty lines if ($_ =~ /^([A-Z]+)\|/) # capture the header { ($header_info) = $1; next DAT; } my($key, $value) = split /\|/, $_; $hash{$header_info}{$key} = $value; } #print Dumper(\%hash); for my $key1 (sort keys %hash) { for my $key2 ( sort keys %{ $hash{$key1} }) { print "$key1:$key2:$hash{$key1}{$key2}\t"; } print "\n"; } __DATA__ JAN| graph|104| success|100| on_time|100| environment|1| builder|3| design|0| FEB| graph|95| success|100| on_time|100| environment|1| builder|3| design|0|