/^\s+$/ needs one or more to skip

Try /^\s*$/

#!perl use strict; use warnings; my $extension = '.txt'; my @files = glob("*.tmp"); for my $file (@files) { open IN, '<', $file or die "$!"; $file =~ s/\..*//; my $outfile = $file.$extension; open OUT, '>', $outfile or die "$!"; <IN> for (1..45); # skip 45 lines while (<IN>) { next unless /\S/; # skip blanks chomp $_; my @F = split ' ', $_; my @array = split m[[:,/]+], $F[9]; my $check = index $F[4],','; if ($check == -1) { my $ratio = $array[3] / $array[4]; print OUT join "\t",@F[0,1,3,4],$ratio,$array[4]; print OUT "\n"; } elsif ($check > 0) { my @allele = split ',', $F[4]; my $ratio1 = $array[3] / $array[5]; my $ratio2 = $array[4] / $array[5]; print OUT join "\t",@F[0,1,3],$allele[0],$ratio1,$array[5]; print OUT "\n"; print OUT join "\t",@F[0,1,3],$allele[1],$ratio2,$array[5]; print OUT "\n"; } print $_; } }
poj

In reply to Re^5: Illegal division by zero error by poj
in thread Illegal division by zero error by TJCooper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.