in reply to running programs from PERL

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: running programs from PERL
by almut (Canon) on Oct 25, 2009 at 10:22 UTC
    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");