I suspect you mean "hang" in the sense of "doesn't seem to be producing any output even after a long time" as opposed to a more precise use of "hang" for "stops consuming CPU but doesn't exit".

The most likely explanation is that the performance of your script is not linear so the much bigger file just takes significantly longer to process. The most likely explanation for seriously non-linear performance given some of what you said is that your process ends up using more memory than your computer can efficiently provide it.

But such possibilities are easy for you to investigate, requiring, at most, some internet searching and minor research to learn a couple of commands and how to interpret part of their output (such as top and ps).

Of course, maybe you have already investigated those possibilities and eliminated them. But I can't tell that based on what little information you provided.

Identifying whether or not the problem is just "using too much memory" is a good step to do before diving into the search for a more specific source of the problem. Hence, I didn't dive into the code you have now added to your posting.

Good luck.

BTW, further updates to your question are better done as replies rather than as modifying the original question. The site does not provide a way for people to notice that you've made an update (while there are several heavily used way to notice new replies). Also, updates tend to make the thread confusing.

- tye        


In reply to Re: Perl script is getting stuck for no reason (swap) by tye
in thread Perl script is getting stuck for no reason by Ankur_kuls

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.