use strict; use warnings; use Data::Dumper; my @proteins=qw( DAAAAATTLTTTAMTTTTTTCKMMFRPPPPPGGGGGGGGGGGG ALTAMCMNVWEITYHKGSDVNRRASFAQPPPQPPPPLLAIKPASDASD ); print Dumper \@proteins; my @new_peptides; for my $protein (@proteins) { if ($protein =~ m/[K(?!P)|R(?!P)]/g) { $protein =~ s/K(?!P)|R(?!P)/=/g; push @new_peptides, split ('=',$protein); } } print Dumper \@new_peptides; for (@new_peptides) { print "The peptide is $_\n"; }