TJCooper has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to process multiple .txt files using a Perl one-liner:
perl -lane 'next unless $. >45; @array = split /[:,\/]+/, $F[2]; print if $array[1]/$array[2] >0.5 && $array[3] >2' input.txt > output.txtThis runs fine on all files individually, however when using:
perl -i.MOD -lane 'next unless $. >45; @array = split /[:,\/]+/, $F[9]; print if $array[3]/$array[4] >0.5 && $array[4] >5;' *.txtIt returns an error of:
Illegal division by zero at -e line 1, <> line 35885.Why is that happening when each individual file runs to completion? Is there a better way to do this?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Process multiple input files using a one-liner
by choroba (Cardinal) on Jan 28, 2016 at 12:35 UTC | |
by Discipulus (Canon) on Jan 28, 2016 at 12:39 UTC | |
by TJCooper (Beadle) on Jan 28, 2016 at 12:54 UTC | |
Re: Process multiple input files using a one-liner
by Discipulus (Canon) on Jan 28, 2016 at 12:53 UTC | |
by TJCooper (Beadle) on Jan 28, 2016 at 13:21 UTC |
Back to
Seekers of Perl Wisdom