in reply to Unknow number show up

Welcome Vkhaw,

I downloaded your code and added structures and executed the script. I didn't get your results, so I commented out the 'system' call and added:

print "$command_line\n";
This would help you know how your re-calling Perl.

Note: you don't need to call Perl in the loop! This adds a lot of memory usage and would be very slow in production. Do the search and save the results to a 3rd file.

Regards...Ed

"Well done is better than well said." - Benjamin Franklin

Replies are listed 'Best First'.
Re^2: Unknow number show up
by Vkhaw (Novice) on Apr 13, 2015 at 16:04 UTC
    Dear Ed,

    When I replace "system" with "print" in my code as you mentioned, it just now working in the sense that nothing happen to my output file. While in command prompt window it give me this type of display

    perl -pi.bak -e s/WL0,BL195(?=,)/WL0,BL195,1708/g; CombineDie1Die2.txt perl -pi.bak -e s/WL0,BL196(?=,)/WL0,BL196,1708/g; CombineDie1Die2.txt perl -pi.bak -e s/WL0,BL197(?=,)/WL0,BL197,1931/g; CombineDie1Die2.txt perl -pi.bak -e s/WL0,BL198(?=,)/WL0,BL198,1931/g; CombineDie1Die2.txt

    I am facing another problem now as my file 1 is about 8 millions line and same as file 2. It took around 3~4 hours only process thousand line. I need a solution for this. Appreciate if you can help.

      Dear Vkhaw,

      The 'print' was to help you see what your 'system' call was doing, not to fix your problem. You have some excellent suggestions from other posters, integrate their suggestions and then post additional questions.

      My current suggestion is to take some time to better understand your file inputs. ie:

      • Are the files sorted in any way? Could they be sorted for performance?
      • Can file2 be loading into an array in memory? That way you read the file once before the loop and then inside the loop, you read file1 a line at a time...Much faster!
      • Do your 's///' directly without re-calling Perl! Much, much faster!
      And please keep asking questions, that's how we all learned!

      Regards...Ed

      "Well done is better than well said." - Benjamin Franklin