my $file = '/home/guest/sampir.txt'); open (PIR, '<', $file) or die "Can't read '$file': $!\n"; my @arr = (); my $se = []; # anonymous record array while() { chomp; if (/^(\w+)\s+/) # new field identifier, followed by blanks { push @$se, $_; } elsif (s/^\s+/ /) # if we can strip leading blanks, # it's a continuation line { $se->[-1] .= $_; # append to last field of this record } elsif(/^\w+$/) # must be the last field of the record { push @$se, $_; # save the last field push @arr, $se; # save the record array reference $se = []; # and make a new array reference for the next record } else { die "Unknown line type at line $. of '$file'\n"; } } #### @arr = ( [ 'ENTRY CCHU #type complete', 'TITLE cytochrome c [validated] - human Homo sapiens', 'ORGANISM #formal_name Homo sapiens #common_name man', 'ACCESSIONS A31764; A05676; I55192; A00001', 'MGDVEKGKKIFIMKCSQCHTVEMGDVEKGGKHKTGPNLHGMIYARAJLFGRKTSEKGQAPGYSYTAANKNKGIIWGEDTLMEYLENPKKYIP' ], [ 'ENTRY CCCZ #type complete', 'TITLE cytochrome c - chimpanzee (tentative sequence)', 'ORGANISM #formal_name Pan troglodytes #common_name chimpanzee', 'ACCESSIONS A00002', 'GDVEKGKKIFIMKCSQCHTSEKVEKGSSSKHKSSSTGPNLHGLMIYARAJFGRKTGSEKQAPGYSYTAANKNKGIIWGED' ], [ 'ENTRY CCMQR #type complete', 'TITLE cytochrome c - rhesus macaque (tentative sequence) Macaca mulatta ', 'ORGANISM #formal_name Macaca mulatta #common_name rhesus macaque', 'ACCESSIONS A00003', 'GDVEKGKKIFIMKCSQSEKCHTVEKGGSSSSKHKTGPNLHGSSEKEMIYARAJKSEKLFGAAAAAAAARKTGQAPGYSYTAANKSSSSNKGITWGEDTLMEYLENPKKYIPGTKMIFVGIKKKEE' ], [ 'ENTRY CCMKP #type complete', 'TITLE cytochrome c - spider monkey', 'ORGANISM #formal_name Ateles sp. #common_name spider monkey', 'ACCESSIONS A00004', 'GDVFKGKRIFIMKCSQCHTVESSSSKGGKHKTGPNLHGLMIYARAJSEKFGSSSSSSSSSSR' ] ); #### print $arr[0]->[1],"\n"; #### TITLE cytochrome c [validated] - human Homo sapiens