Hello all,

I am trying to use backticks like so: my @result = `command --arg1=$num1 --arg2=file.log  . . . -argLast=$numLast`;

I can see from the log file that the command is processing and on some occaisions I have even seen the log file say the command was finished, however the rest of my perl script does not run, instead the command starts to run again.

I was thinking about adding something like exit if $?=0 inside of the backticks to force the script to move on, but I think this not quite right. I've read that backticks are supposed to hand over control to the parent script after it runs so I really don't even want to force it to continue.

Any thoughts on what might be going on?

I'm sorry for asking such a basic question and vague questions. I will try to provide any details you would like. But unfortunately I didn't write all of this code, and it is sort of privately owned, so I can't exactly put up the code verbatim.

Thanks very much.

Thank you all so much for your help. I figured out what was wrong thanks to, Anonymous-Monk (01:34 UTC).

It turns out there was a for loop in my code. It was about 500 lines up. I did not notice it before beacuse the original perl script that I am manipulating called an old suite of C programs that we no longer use. Using the old stuff each loop finished in 2-5 seconds. Now that we make calls to a new set of C code each for loop takes 2000s. This is certainly not an improvement and something else I have to look into.

Thank you again.


In reply to Backtick caught in infinite loop by tau1777

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.