in reply to Re^4: Error when running on larger files
in thread Error when running on larger files

Hm. Other than having to add a line to discard the header; your file processed to completion without error.

Two possibilities:

  1. (Unlikely) The data file is corrupted on disk with a bad block or similar.

    Copy the file to another name (or unzip the zip you posted) and try that.

  2. (More unlikely). Your perl installation is broken.

    Install another version and try again.

Beyond those we're into a world of even more speculative guessing.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.
  • Comment on Re^5: Error when running on larger files

Replies are listed 'Best First'.
Re^6: Error when running on larger files
by martell (Hermit) on Jun 28, 2016 at 10:25 UTC

    I tried also to run the code on the file. It's run perfectly on my system after throwing away the header.

    I still suspect you have somewhere unexpected characters in your input. The errors point to that. This can be invisible characters that aren't visible and can't be automatically transformed by Perl to a number. Try to validate your input by something like this:

    unless ($F2[2] =~ /^[+-]?\d+\.?\d*$/) {print "not an floating number\n +";} #assumes "." as digital separator, no thousand separator unless ($F3[2] =~ /^[+-]?\d+\.?\d*$/) {print "not an floating number\n +";}

    Look also to http://www.perlmonks.org/?node_id=622704 for a more in detail explanation. It is possible that later versions of Perl are more robust in transforming a string to a number.

    Martell

Re^6: Error when running on larger files
by K_Edw (Beadle) on Jun 28, 2016 at 10:14 UTC

    How bizarre. I've tried running it on 5.25.2 and 5.24.0 installed via Perlbrew. Same error each time.

    It seems to be caused by something earlier in the script (this chunk of code forms a subsection of it) - running my file using your wrapped code allows it to run to completion.

    Why exactly it fails near the end of a file when it's part of a larger script but not when it's separate is beyond me.

      It seems to be caused by something earlier in the script

      Does the earlier code read the same file? Does the earlier code use much memory?

      Perhaps you should post the entire script.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.

        I've found the cause. I used incorrect syntax to try and close multiple filehandles

        close ($OUT,$OUT2,$IN)

        But despite using warnings + strict, I never received a message about this until I switched back to the system Perl. As the input file for this chunk of code is created earlier in the script - not having the filehandle closed led to the error.

        I'm still unclear as to how the script was able to run to completion on some, typically smaller input files - but not others given that almost no memory is required until this step.