-rw-r--r--. 1 mala mala 21M Mar 23 2015 SGSN225374.1.201412260345.20 +6040 -rw-r--r--. 1 mala mala 21M Mar 23 2015 SGSN225374.1.201412260345.20 +6059 -rw-r--r--. 1 mala mala 21M Mar 23 2015 SGSN225374.1.201412260345.81 +8393 -rw-r--r--. 1 mala mala 21M Mar 23 2015 SGSN225374.1.201412260345.81 +8410 -rw-r--r--. 1 mala mala 19M Mar 23 2015 SGSN225374.1.201412260345.81 +8411

I am dealing with bigger files. If I use open its occupying my primary memory. Is there any way to do by not occupying my memory.

FAIL_IN_RAU_MME_TO_2GSGSN,0; 4,12017,184,10373,405,25,100,0,0,0,5,0,25,64000,64000, INT_ID,88320, PERIOD_START_TIME,20141226034500, PERIOD_STOP_TIME,20141226040003, PERIOD_DURATION,15, PAPU_INDEX,4, LAC,12017, RAC,184, CI,10373, SUCC_GPRS_ATTACH,1, FAIL_GPRS_ATTACH,0, SUCC_COMBINED_ATTACH,0, FAIL_COMBINED_ATTACH,0, SUCC_IMSI_ATTACH,0, FAIL_IMSI_ATTACH,0, GENERAL_UNDEF_ATTACH_FAILURE,0, SUCC_INTRA_PAPU_RA_UPDAT,0, FAIL_INTRA_PAPU_RA_UPDAT,0, SUCC_INTRA_PAPU_RA_LA_UPDAT,0, FAIL_INTRA_PAPU_RA_LA_UPDAT,0, SUCC_INTRA_PAPU_RA_UPDAT_IMSI,0, . . . . FAIL_IN_RAU_MME_TO_2GSGSN,0; 4,12017,184,10383,405,25,100,0,0,0,5,0,25,64000,64000,

The above is sample data of my CDR. In that I need to read the line  FAIL_IN_RAU_MME_TO_2GSGSN,0; for that

$cmp=substr(reverse($line),0,1); if ($cmp eq ";") {

But that event occurs for an average of 400 lines once. Its there any better way to do that??? Thanks for every answer in Advance.

Update:

As you are suggested I change the code into pieces and run the file opening & reading script (part of my original code) with a sample data (5files). Here I am printing the size of the hashes and memory usage(RAM) while reading files. As you said it's not taking any memory for reading files. But for hashes its using huge memory

%rac_val :4465260 This is equal to 4Mb. I got this for 5 files. But I have nearly 3800 files to process. This is what my memory is eating. How to manage this????

Output: perl generate_nsn_sgsn_report.pl 20141226 Memory Usage : 77.70% #at the starting stage the + usage of RAM 120 120 120 120 120 120 120 120 120 120 Rac Val :120 120 120 120 Memory Usage : 77.70% #Checking the ram usage after opening every fi +le Memory Usage : 77.71% Memory Usage : 77.71% Memory Usage : 77.72% Memory Usage : 77.75% %val :120 %seen_cdr :212 %seen_var :4152 %pap_data :1858 %mcc_data :629 %mnc_data :1085 %sgsn_val :102895 %sgsn_name :102893 %pap_val :699127 %mcc_val :231276 %rac_val :4465260 %nsei_data :120 %nsvci_data :120 %nsvc_val :120 the code took:49 wallclock secs (48.76 usr 0.06 sys + 0.01 cusr 0.0 +2 csys = 48.85 CPU)

In reply to Alternate for "open" by ravi45722

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.