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

basicdez has asked for the wisdom of the Perl Monks concerning the following question:

Please help me with your infinite wisdom. I am pulling in a .dat file as an input file to my perl module usinf the following:

my $fname = "$datpath2/pd2x.dat2";

I am accessing the contents via:

open FH, "< $fname" or die "Cannot open datfile: ", $!; while (<FH>) { if (/"DESTINATION"/) { . . .

Whenever I get an input file greater than 45,000+ bytes my perl module comes to a stand still. Anything less than this and it runs just fine. What do I need to do to be able to input a larger file.

I apologize for being a novice

peace, LOVE and ((code))
basicdez


Edited: ~Fri Oct 18 21:32:21 2002 (GMT) by footpad: Added <code> tags and other HTML formatting to improve legibility, per Consideration

Replies are listed 'Best First'.
Re: Increasing buffer size(?) for input FileHandle
by Aristotle (Chancellor) on Oct 18, 2002 at 14:08 UTC
    Perl imposes are no limits on any variables other than the available memory. Try adding a few prints in there, right after you read a line, before you call the function, after, and so on. I suspect it is the function you call that for some reason chokes on input larger than 44k; by adding prints you'll be able to verify at which point in time exactly things go awry.

    Makeshifts last the longest.

Re: Increasing buffer size(?) for input FileHandle
by janx (Monk) on Oct 17, 2002 at 20:55 UTC
    Just a few thoughts:
    1. Are there any line breaks in that file?
      The "<FH>" will read in one complete line - though I don't think your system should have a problem with a 45000 byte line.
    2. What exactly do you mean by standstill? Can you take a look at exactly how much memory your program consumes?
    3. Are possibly running into an infinite loop somewhere? It might be embarrassing, but sometimes...you know ;-)

    janx

      by standstill I mean that the code just stops working and goes back to the previous input buffer to send a message back to the area I am attempting to interface with.

      with the open FH command, isn't there some way that I can reset the buffer size to something larger?

      peace, LOVE and ((code)) basicdez