#!/usr/bin/perl -w use strict; open my $Gpff, '<', 'protein.gpff' or die "protein.gpff: $!\n"; my ($key, %data); while (<$Gpff>){ chomp; if (/^(?:\s\s)?([A-Z]+)\s+(.*)$/){ $key = $1; $data{$key} = $2; } else { s/^\s+/ /; $data{$key} .= $_; } } close $Gpff;