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.
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.>>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;
thanx
In reply to module problems by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |