use strict; use warnings; open IN, "zea_mays.txt"; open OUT, ">zea_mays1.txt"; my @peptides; my $seq; my $flag = 0; while(my $line = ){ chomp($line); #check the chomp function if ($line =~ /^>/) { if ($flag == 0){ #the first protein entry, which means nothing in the memory to do $flag = 1; next; } print "\n"; print OUT " $line\n "; }else { $line =~ s/\s//g; my @peptides = split(/(?<=[RK](?!P))/,$line); print OUT "@peptides\n"; } } close IN; close OUT; #### my(@lines) = '/tmp/zea_mays.txt'; #### while ( defined( my $line = readline \*IN ) ) { do { foreach $line (@lines) { #### my (@peptides) = split( /(?<=RK(?!P))/, $line );