The temporary @args array is not needed, use system($dir,'&').

That's right. But it doesn't do much harm either... And in case you want to debug what is actually being passed to system, you can simply add a print @args without restructering the code, instead of duplicating the argument list and trying to keep both in sync when you make changes. This is especially handy with more unwieldy (OT: or would you say unwieldier?) argument lists. You never know when you'll need it...

my $prog = 'myprog'; my $file = 'myfile'; my @useropts = qw(-bar -baz); my @args = ("/path/to/$prog", '-foo', @useropts, $file, '-o', "$file.o +ut"); print "system(): @args\n"; # debug system (@args); # vs. print join(" ", "system():", "/path/to/$prog", '-foo', @useropts, $fil +e, '-o', "$file.out"), "\n"; # debug system("/path/to/$prog", '-foo', @useropts, $file, '-o', "$file.out");

In reply to Re^2: running programs from PERL by almut
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.