while(<$IN>){ chomp; if (m/$start/) { $name = $1; next; } elsif (m/^record size:\s+(\d+)/) { $Hash{$name}{'record_size'} = $1; next; } elsif (m/^last record:\s+(\d+)/){ $Hash{$name}{'last_record'} = $1; next; } elsif (m/^data byte count:\s+(\d+)/) { $Hash{$name}{'data_byte_count'} = $1; next; } elsif (m/^\s+index name:\s+(\w.*)/) { push(@{ $Hash{$name}{'indexes'} }, $1); next; }else{ next; } } close $IN; foreach my $key (keys %Hash) { print $OUT "File: $key
\n"; print $OUT "\tRecord Size: $Hash{$key}{'record_size'}
\n" if defined $Hash{$key}{'record_size'}; print $OUT "\tLast Record: $Hash{$key}{'last_record'}
\n" if defined $Hash{$key}{'last_record'}; print $OUT "\tData Byte Count: $Hash{$key}{'data_byte_count'}
\n" if defined $Hash{$key}{'data_byte_count'}; if (defined $Hash{$key}{'indexes'}){ my $str = join ', ', @{ $Hash{$key}{'indexes'} } ; print $OUT "Index Names: $str

\n"; }else{ print $OUT "

\n"; } } }