hi,

well i have some problems with creating module, actually there wouldn't be any problems in the first place if the the perl could force erasing the data from the memory, while it is still working on the problem. well now i'm trying to separate functions by creating modules, but there are some problems like , i want to put a subroutine into the module, that takes some data from the main script, passes it into the sub(which is in the module), sub rearranges it and returns it into the variable in the main script.

>>MAIN SCRIPT<< use strict; use bignum; use Temp; my $f=@ARGV[0]; for (my $xx = 1;$xx<=100;$xx++){ my $x=Fact($f); print "$x"; } >>Module<< package Temp; sub Fact{ my $d = $_[0]; my $h =1; for (my $i = 1; $i<=$d; $i++){ $h *=$i; } return $h; } 1;
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.

thanx


In reply to module problems by baxy77bax

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.