thanks for the reply. Apologies if this isn't clear I tried to keep it concise as possible so not to overload with code. This wasn't directly from my code so will paste a larger part see if it makes sense. The code is admittidely very ugly but its doing a very specific job. The @sequences is a list of two strings separated by a tab defined earlier still in the programme. @searchmotif is a short list of things to search for. I don't think I need to split the $temp3[0] into an array can just pattern match it but thought I'd leave this as it was written to see if it is clearer The larger bit of code is:
foreach my $line4 (@sequences) {my @temp3 = split ( '\t', $line4); my $counter = 0; my $paa = chop ($temp3[0]); my @fouraas = split ( '', $temp3[0]); if ($paa =~ /s/i ) {$pStotal++; foreach my $key (@searchmotif) {unless ( my @stemp = grep ( /$key/, @ +fouraas)){ push (@{$nsaminoacids{$key}},$temp3[1]);next;} #closes if +loop else { push (@{$saminoacids{$key}},$temp3[1]); next;} #closes if +loop } #close foreach loop } #closes if S loop elsif ($paa=~ /t/i ) {$pTtotal++; foreach my $key (@searchmotif) {if (my @ttemp = grep ( /$key/, @foura +as)){ push (@{$taminoacids{$key}},$temp3[1]); } #close +s if loop else { push (@{$ntaminoacid +s{$key}},$temp3[1]); } #close +s if loop } #close while loop } #closes if T loop elsif ($paa =~ /y/i ){$pYtotal++; foreach my $key (@searchmotif) {if (my @ytemp = grep ( /$key/, @foura +as)){ push (@{$yaminoacids{$key}},$temp3[1]); } #close +s if loop else { push (@{$nyaminoacids{$k +ey}},$temp3[1]); } #close +s if loop } #close while loop } #closes if Y loop else {push (@error, "$line4\tNot recognised p amino acid\n"); } } #closes foreach loop
i really don't understand why its not only using one of the actions after the unless command. This whole section if almost affectively just 3 repeats of what I posted ealier.
In reply to Re^2: Updating arrays within hashes
by jonnyw83
in thread Updating arrays within hashes
by jonnyw83
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |