TJCooper has asked for the wisdom of the Perl Monks concerning the following question:
I'm currently using two one-liners to 1. Extract information from a tab-delimited .txt file and then 2. Replace a set of strings within the newly created file:
perl -lane '$w = "w"; $l = length($F[9]); print "$w\t$F[2]\t$F[3]\t$l" if $F[1] =~ 99; $w = "c"; $l = length($F[9]); $p = $F[3]+$l; print "$w\t$F[2]\t$p\t$l" if $F[1] =~ 83; print "Head1\tHead2\tHead3\tHead4" if $.==1;'perl -ane '$F[1] =~ s/A/B/; $F[1] =~ s/C/D/; $F[1] =~ s/F/G/; say join "\t", @F'
Is there a way to combine these into a single line such that it performs this replacement before printing the new file?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Performing search and replace on an output file prior to printing
by Eily (Monsignor) on Jan 26, 2016 at 09:55 UTC | |
by GotToBTru (Prior) on Jan 26, 2016 at 13:38 UTC | |
by choroba (Cardinal) on Jan 26, 2016 at 13:41 UTC | |
by Eily (Monsignor) on Jan 26, 2016 at 16:18 UTC | |
by Anonymous Monk on Jan 27, 2016 at 13:44 UTC |