in reply to module problems

also how can i make that every time it finishes it with the module , it terminates that script (.pm). like in the example -- every time it finishes with the for loop in the main program it closes the .pm and then every time that opens the for loop it opens the .pm script.

Why would you want to do this? Without knowing that, I'm not sure anyone can give you a good suggestion.

Replies are listed 'Best First'.
Re^2: module problems
by baxy77bax (Deacon) on May 16, 2008 at 20:33 UTC
    ok i want to do the same thing as:
    for(my $i...){ system ("perl foo.pl X Y"); ... }
    but this seams as pretty "hammered" way to do this . Why? because this is the only way i now how to clear my memory, all other functions do not work, if i don't do this it seams that perl looses the tag that tells him where he left some peace of data, and he can't clear the memory every time he repeats the process (so i have a hudge memory leakage). memory builds until there is no free memory left so the program crashes finaly.

    :)

      Given that leaks are often an indication that there a foible (bug?) in the code maybe a better thing would be to track down and fix the leak?

      Tools such as Devel::Size, Devel::Leak and Devel::DumpSizes will help. Note that if you want to use Devel::Leak with recent versions of Perl apply the patch at rt://22587 (thanks lima1). The discussion in Tracking down memory leaks may be of some help.

      On a different topic: Your C is showing! The Perlish way to iterate over a range is:

      for my $index (1 .. 500) { }

      which is shorter, clearer and more maintainable.


      Perl is environmentally friendly - it saves trees