Jagadeesh
5/25/2009 3:44:00 PM
On May 25, 4:44 pm, Robert Klemme <shortcut...@googlemail.com> wrote:
> 2009/5/25 Bertram Scharpf <li...@bertram-scharpf.de>:
>
>
>
> > Hi,
>
> > Am Montag, 25. Mai 2009, 17:30:43 +0900 schrieb Robert Klemme:
> >> 2009/5/25 Mohit Sindhwani <mo_m...@onghu.com>:
> >> > Jagadeesh wrote:
> >> >> [sample perl code]
> >> >> $CMD = join(' ', $cmd, $arg1, $arg2, $arg3);
>
> >> > Not 100% sure of what you need, but I think this will do the job for you:
> >> > str = [cmd, arg1, arg2, arg3].join(' ')
>
> >> If this is for executing an external process, there is no need to lump
> >> all these together, instead you can do which has the advantage that
> >> you do not need a shell to parse the individual arguments and also
> >> whitespace cannot cause trouble.
>
> >> system cmd, arg1, arg2, arg3
>
> > There are two more advantages: Arguments that contain spaces
> > remain one argument.
>
> That's what I meant (see above).
>
> > Arguments that contain shell operators like
> > ; && || `...` could produce malicious side effects.
>
> Hehe, true!
>
> > Another approach:
>
> > args = [ arg1, arg2, arg3]
> > system cmd, *args
>
> What advantage would it have to first create that array 'args'?
Well this approach also look neat and readable.
Thanks