rfransix has asked for the wisdom of the Perl Monks concerning the following question:
O Wise and Awesome Monks, a text file contains lines of fields seperated by some delimiter; space for example; some lines not all will have in field 2 a value like an inital (e.g., A. or B. or Jr.) for those lines with such a value in field 2, we wish to have that value removed or deleted. We also wish to do this as a one-line. Here's what we have so far. What say you?
c:\perl\bin\perl.exe -e "while (<>) { next if ($F[2] ~= /A-Za-z/\.;) print \"\"}" < text.txt > xt.txtor
c:\perl\bin\perl.exe -e -i.bak "while (<>) { next if ($F[2] ~= /A-Za-z/\.;) print \"\"}" text.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: On Match Remove Field
by AnomalousMonk (Archbishop) on Mar 03, 2011 at 21:19 UTC | |
by rfransix (Novice) on Mar 03, 2011 at 22:33 UTC | |
|
Re: On Match Remove Field
by TomDLux (Vicar) on Mar 03, 2011 at 21:27 UTC | |
|