http://qs321.pair.com?node_id=1153843

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.txt

This 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;' *.txt

It 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?