Hello bsachin,

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}

In reply to Re: return a value from perl script to perl module call ing the script by shmem
in thread return a value from perl script to perl module call ing the script by bsachin

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.