2009/5/25 Mohit Sindhwani <mo_mail / onghu.com>:
> Jagadeesh wrote:
>>
>> Hi,
>> I am looking for something similar to join in perl. I am doing
>> [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(' ')

Alternative approaches:

str = "#{cmd} #{arg1} #{arg2} #{arg3}"
str = sprintf '%s %s %s %s', cmd, arg1, arg2, arg3

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

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/