Dear Monks, I gained some additional wisdom about the function 'do' which I would like to share.
I used the do function in the first script to execute the second script in the same context (shared memory without creating another process by using system(..)). Though, I had to pass some arguments to the second script. do "2.pl $arg1" does not work.
Finally I came to know that if we want to pass argument to the second script, we can exploit the idea that @ARGV will be visible to the second script. I achieved the goal as below:
use my_module;
print "@my_var\n"; # prints 1..10
change_var();
print "@my_var\n"; # prints 20..30
{ # using local to supress @ARGV
local @ARGV = ($arg1, $arg2...); # $arg1, $arg2... are the argumen
+ts to be passed
do "2.pl";
}
exit;
Now, in 2.pl I can get these arguments using shift.
Regards,
--Anupam
|