perldoc -f substr for more info, on Unix
Seearch for: a literal question mark character, followed by any number of any characters; replace all that with: nothing ( i.e., delete it )
Proceessing input files line by line is the best way to do it, unless there are reasons for processing larger chunks. hint: most of the time, when you think you need to process larger chunks, what you really need is to find a different way of thinking about the process.
In the then clause, you chop( $qnum ), removing the last character. Or is this supposed to be the reverse-chop, from part 1? In any case, $qtext continues to end with a newline character.
In the else clause, you chomp( $qspec ). chomp() is like chop(), except it removes only the current $INPUT_RECORD_SEPARATOR, $/, normally "\n". $qspec can't have a newline, since it comes from the middle of a line. But $x ends with a newline.
I would suppose using chomp() right after the while(), to trim newlines from all input.
Update: I forgot the most important part ... You left out "use strict;", and you should localize your variables with my.
--
TTTATCGGTCGTTATATAGATGTTTGCA
In reply to Re: Using perl interactively with VI
by TomDLux
in thread Using perl interactively with VI
by NovMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |