Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
One-liner only checking the first line of the input fileby TJCooper (Beadle) |
on Nov 11, 2015 at 14:17 UTC ( [id://1147450]=perlquestion: print w/replies, xml ) | Need Help?? |
TJCooper has asked for the wisdom of the Perl Monks concerning the following question: I have an 8-column input tab-delimited .txt file and wish to print the contents of column 3 + 8 when the value held within column 8 is >0. I've tried: perl -lane 'print "$F[2]\t$F[7]" if $F[7] > 0' < input.txtHowever this only returns a single line (the first line) when there are multiple matching lines. I want it to iterate over every line instead. What have I done wrong? For example, if my input file contains: 77 * 10 0 * * 0 340 141 * 40 0 * * 0 240 The output file will only contain: 10 340
Back to
Seekers of Perl Wisdom
|
|