in reply to return a value from perl script to perl module call ing the script
what reasons do you have to not call the test.pl script from within the current perl process (the one that is executing test_main.pl) ? Must it be that separate from your main script?
You can always load and execute a script once via the do FILE mechanism. For example, having the main script
#!/usr/bin/perl # script test_main.pl use test1; my $var = test1::abc('test.pl'); print $var,"\n";
and the module file
# file test1.pm package test1; sub abc { my $file = shift; my $variable = do $file; }
which calls from sub this file:
# file test.pl my $time = scalar localtime time; $time;
then the script test_main.pl loads test1.pm and calls the subroutine abc with a filename as argument. The subroutine abc form test1.pm loads and executes the file. The last expression evaluated in that file is $time, so that value is returned by do and stuffed into the private $variable - which is passed to to the mainscript (it's the last expression of the subroutine), stored there into $var and printed out.
See do. See also require, use, system, and read about the "quote and execute" qx operator in perlop.
Calling perl from a perl script via system is almost always a bad idea.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|