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

Removing text to the end of the line.

Thread Next
David Buddrige
December 19, 2002 23:20
Removing text to the end of the line.
Message ID:
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:

     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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About