http://www.perlmonks.org?node_id=120855


in reply to Re: Array for system() call
in thread Array for system() call

To elaborate further, use this (note double quotes): system("@Call"); instead of this: system(@Call); to achieve the same effect as your first fragment.

And, BTW, you probably meant to do this:

$Call[0] = "gawk"; $Call[1] = "-f"; $Call[2] = "test.gawk"; $Call[3] = "test.file"; $Call[4] = ">"; $Call[5] = "out.file";

or (slightly more efficiently) this:

@Call = ( "gawk", "-f", "test.gawk", "test.file", ">", "out.file" );

rather than your original code, which is assigning values to 1-element array slices, which are sublists -- NOT arrays! -- of references to the elements of the @Call array; needless to say, although it works, it is somewhat less efficient than either of the above approaches, and bad practice besides.

dmm

Give a man a fish and you feed him for a day ...
Teach the man to fish and you feed him for a lifetime