Beyond Alexander's tips, there's one more thing that bugs me:

You chdir to $current_dir, then prepend $current_dir/ to your command. Works nicely on Unix for $current_dir being absolute or . or ./. . But for "" or a non-trivial relative path, you're in for a surprise... .

One way to cope is prepending $ENV{PWD}/ to a relative path. Note that $ENV{PWD} isn't updated by chdir(), being set by the shell. Note 2: Better yet, check Anonymous' File::chdir pointer below and prepend $CWD instead (thx, this elimininates most of the chdir pains! Note2Self: my($CWD) stops the chdir side effect of assigning. Good.).


Ad afoken's warning on using the shell:

If you restrict yourself to Unix (and CYGWIN), you normally can assume at least a Bourne-style or POSIX shell, which allows a nice idiom using %ENV to avoid severe secure quoting headaches: $ENV{f}="...";system qq{ls -l -- "\$f"};.

Open Question: Windows processes should support %ENV as part of their POSIX support. What is be the corresponding secure Windows-NON-CYGWIN-idiom for the Unix shell's variable interpolation w/o word splitting, i.e. "$f"?

cu & HTH, Peter -- hints may be untested unless stated otherwise; use with caution & understanding.

In reply to Re: running programs from PERL by jakobi
in thread running programs from PERL by metalnut

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.