In the original you are searching for two strings in the same line but in the new version you are searching for one string in one line and the other string in the next line.
Also, you are using the high precedence || operator which means that the program will not die if open fails because you are testing the boolean state of the string 'sample.fa' or the string '>modsample.fa' which are always true.
You probably want something like this:
open IN, '<', 'sample.fa' or die "Could not open 'sample.fa' becau +se: $!"; open OUT, '>', 'modsample.fa' or die "Could not open 'modsample.fa' be +cause: $!"; my $previous; while ( my $line = <IN> ) { if ( $previous && $line =~ /mamma/ && $line =~ /mia/ ) { print OUT $previous, $line; } else { print "."; } $previous = $line }
In reply to Re: What went wrong with this change in code?
by jwkrahn
in thread What went wrong with this change in code?
by naturalsciences
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |