On Sep 20, [EMAIL PROTECTED] said:

>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. For this I have written
>a code as follows:
>
>while(<OUT1>) {
>        if(/FINAL/) {
>                chomp($_);
>                $_ =~ tr/FINAL//d;
>                $sec_seq1 = $sec_seq1 . $_;
>        }

You're using tr/// when you should be using s///.

  while (<OUT1>) {
    if (s/FINAL//) {
      $sec_seq1 .= $_;
    }
  }

Try that.  tr/// is not for regexes, it is for transliterating a set of
characters to another set of characters.

  # turn a lettered phone number into a regular phone number
  my $phone_number = "1-800-ABC-DEFG";
  $phone_number =~ tr/A-Z/22233344455566677778889999/;

-- 
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart


-- 
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