John W. Krahn wrote:
[EMAIL PROTECTED] wrote:
I have a file which contains a number of instances of the word
"FINAL". I need to truncate all the instances of this word and
create an output string of the rest of the words in the same line
in the file. Rest all lines not containing the word are to be
ignored.

<snip>

it still leaves spaces in all the occurences of the word.

If I understand your problem correctly then this should work:

while ( <OUT1> ) {
    chomp;
    s/\s*FINAL|FINAL\s*//g and $sec_seq1 .= $_;
    }
}

I fail to see how "FINAL\s*" ever can match if "\s*FINAL" doesn't match.

It's unclear to me (too?) what exactly the OP wants to do with the
spaces, but this would replace the word "FINAL" and possible
surrounding spaces with one space character:

    s/\s*FINAL\s*/ /g

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to