in reply to system commands with spaces

Hi :) The cure is in the manual for exec
@args = ( "echo surprise" ); exec @args; # subject to shell escapes # if @args == 1 exec { $args[0] } @args; # safe even with one-arg list
system { $args[0] } @args; is not subject to shell escapes. Cheers

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: system commands with spaces
by dpuu (Chaplain) on Apr 09, 2004 at 16:46 UTC
    Yes, that's probably a better implementation than quoting $_[0]. But the idea of wrapping the system() call to make it DWIM still seems like a win. The concept of the system interface is that you can call it with either a list or a scalar and it will do the right thing. Having to use a different syntax for the special case of a 1-item list (with spaces) doesn't feel right -- especially when its a simple hack to have perl figure this out for me.