What do you mean "slows down your script"? If you are running it thru system or backticks, your script will have to wait for it to complete, before continuing. If "myscript" involves a long process, then you just have to wait. It wouldn't be any faster if you put the guts of "myscript" into a subroutine into your original script. You will still have to wait for that subroutine to do it's work and return. The amount of time it takes for Perl to compile the script is neglible, unless you are repeatedly calling it 100's of times.

So what are your options? If you don't need "return values" from "myscript" (like if it is mailling something), you can do a "fork-and-exec" to run it, which will let your main program continue running at full speed.

The tricky part, is if you need return values. In that case, there is IPC, POE and GUI's which use event loops like Tk, Gtk2, Wx , etc. You can also setup some pipes and pipe your data back from a fork and exec.

Since you claim your problem is the -h option, preventing a require, why not make a copy of "myscript" and call it myscript1, and just hardwire the -h option into it, and require it? I have a feeling that it won't fix your problem, because it involves a time consuming process.


I'm not really a human, but I play one on earth. flash japh

In reply to Re: shelling out too much by zentara
in thread shelling out too much by iblair

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.