Nov 8, 2002 #1 user2base Technical User Joined Oct 16, 2002 Messages 29 Location GB I have a file that looks like this: blabla ! ! ! bla bla ! bla blablabla ! ! etc... How to remove all the ! in a series but one so that the result looks like: blabla ! bla bla ! bla blablabla !
I have a file that looks like this: blabla ! ! ! bla bla ! bla blablabla ! ! etc... How to remove all the ! in a series but one so that the result looks like: blabla ! bla bla ! bla blablabla !
Nov 8, 2002 #2 Zas Programmer Joined Oct 4, 2002 Messages 211 Location US whats you data output when you make the file? Upvote 0 Downvote
Nov 8, 2002 #3 justice41 Programmer Joined May 29, 2002 Messages 755 Location US You can set a 'seen' flag if a line contains a '!' and then skip any other lines after that which contain a '!'. A simple example: Code: my $seen = 0; while (<DATA>) { next if $seen and /^!$/; $seen = /^!$/ ? 1 : 0; print; } jaa Upvote 0 Downvote
You can set a 'seen' flag if a line contains a '!' and then skip any other lines after that which contain a '!'. A simple example: Code: my $seen = 0; while (<DATA>) { next if $seen and /^!$/; $seen = /^!$/ ? 1 : 0; print; } jaa