Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Keeping the first occurence of a pattern, and removing the other occurencesby TStanley (Canon) |
on Aug 04, 2011 at 15:42 UTC ( [id://918572]=perlquestion: print w/replies, xml ) | Need Help?? |
TStanley has asked for the wisdom of the Perl Monks concerning the following question:
I have the following report: What I am trying to get rid of, is the second or more occurences of the department name. The first instance after the store name is fine, but the others are not. My thought is to split the file into records based on the form feed character, then work on each record. So the initial code would be: One thing consistent through the file is that the occurences of the department name that I need to remove occur before the header lines, so I'm guessing a regex similar to: would do what I need. Am I heading in the right direction with this guess, or am I going in the wrong direction? TStanley -------- People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf. -- George Orwell
Back to
Seekers of Perl Wisdom
|
|