ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
-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.
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
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Alternate for "open"
by 1nickt (Canon) on Nov 16, 2015 at 06:44 UTC | |
by ravi45722 (Pilgrim) on Nov 16, 2015 at 08:16 UTC | |
by Corion (Patriarch) on Nov 16, 2015 at 08:27 UTC | |
by 1nickt (Canon) on Nov 16, 2015 at 15:18 UTC | |
by ravi45722 (Pilgrim) on Nov 17, 2015 at 04:53 UTC | |
by Corion (Patriarch) on Nov 17, 2015 at 07:35 UTC | |
by Preceptor (Deacon) on Nov 16, 2015 at 17:24 UTC | |
|
Re: Alternate for "open"
by 2teez (Vicar) on Nov 16, 2015 at 06:54 UTC | |
|
Re: Alternate for "open"
by Preceptor (Deacon) on Nov 16, 2015 at 17:24 UTC | |
by ravi45722 (Pilgrim) on Nov 17, 2015 at 05:02 UTC | |
by 1nickt (Canon) on Nov 17, 2015 at 07:47 UTC | |
by ravi45722 (Pilgrim) on Nov 17, 2015 at 08:29 UTC | |
by Preceptor (Deacon) on Nov 17, 2015 at 11:34 UTC | |
| |
by Preceptor (Deacon) on Nov 18, 2015 at 14:41 UTC | |
by Preceptor (Deacon) on Nov 17, 2015 at 11:38 UTC | |
|
Re: Alternate for "open"
by u65 (Chaplain) on Nov 16, 2015 at 11:38 UTC | |
|
Re: Alternate for "open"
by 1nickt (Canon) on Nov 17, 2015 at 15:02 UTC | |
by ravi45722 (Pilgrim) on Nov 18, 2015 at 04:24 UTC |