in reply to Bioinformatics: Regex loop, no output
Maybe like this?
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"; }
I use Data::Dumper all the time because I've been fooled by my data too many times. ;-)
In Section
Seekers of Perl Wisdom