You've now been given several suggestions:
- use strict;
- use warnings;
- Test by simplifying the script so that it only opens the files
- Make sure to use while not foreach to read your filehandles
- Post verbatim snippets of the code here so it can be reviewed
Which of these have you done?
In particular, does your code contain use strict; and use warnings;?
It's not an completely unreasonable idea to try to measure the memory footprint of your hash, but most monks here would not do that to find the problem. Better to simplify your code so you can identify the problem.
Just remove everything until it runs properly, then start adding stuff back in. If it is a really large and ugly codebase, take the opportunity to refactor and move code out into modules. This is better practise for many reasons and will help you do this kind of debugging by making it easy to use and not use parts of the code.
You could also:
-
If you suspect the hash is getting too big, comment out the code that populates it, run the program, and see if there's a difference.
-
Try running the program on only one file and see if there's a difference.
-
Try running the program on lots of very small files and see if there's a difference.
-
Consider loading your file data into a real database such as SQLite and working from there.
-
Look for memory leaks with Test::LeakTrace
There, now you have a bunch more suggestions. It will be nice to hear back from you when you've tried some of them and you are still stuck.
The way forward always starts with a minimal test.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.