Let me start by saying that I'm not a programmer. I'm a scientist. Perl is a tool that I can use to do my science, but I don't need to be an expert, write beautiful code, or find the optimal solution to every coding problem. I just want the quick and dirty answers that will allow me to do what I want to do in some semi-reasonable way.

That being said, here's my problem. I have a bunch of perl scripts that work just fine on my old linux box. Now, I have a shiny new desktop with two quad processors. The system install of perl is built with threading enabled by default. This is great for some scripts, but it causes others to die when a line of code that depends on results from a previous line gets executed before the previous line has finished its job (for instance, a system() call creates a file, but the code tries to access the file before the system call is done making it).

I don't want to install my own local version of perl, or have the syshelp people reinstall perl without threading, since I get a benefit in some cases. I also don't want to have to re-write all of my code line by line to make sure it's robust to threading. What is the most elegant and most SIMPLE solution here? Is there a way to run a perl script without threading "turned on" under thread-enabled perl? Do I really have to litter my scripts with statements like "if threading is enabled do this, otherwise do this" if I want them to run under threaded and non-threaded perl?

It seems like this should be simple, but I haven't had any luck so far, so any advice will be appreciated.


In reply to Runing "regular" code with threaded perl by kingskot

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.