develooper Front page | perl.beginners | Postings from December 2002

Removing text to the end of the line.

Thread Next
From:
David Buddrige
Date:
December 19, 2002 23:20
Subject:
Removing text to the end of the line.
Message ID:
3E02C3D4.50200@switch.aust.com
Hi all,

I have a bunch of C++ source files that contain the string

PCN: sometext

where somtext is an arbitary sequence of characters.

Whenever the text "PCN:" occurs, I want to remove it and everything else 
to the end of the line.

To do this, I have written the following script:

while(<>)
{
     my $current_line;

     $current_line = $_;
     $current_line =~ s/PCN:[.]*//g;

     print $current_line;
}


However this only removes the "PCN:" part, leaving the rest of the 
string that occurs between the PCN: and the new-line undisturbed.  Is 
there some way that I can tell perl that I want it to remove everything 
from PCN: onwards to the end of the line?

thanks heaps guys

David Buddrige.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About