On May 25, 1:30=A0pm, Robert Klemme <shortcut... / googlemail.com> wrote:
> 2009/5/25 Mohit Sindhwani <mo_m... / onghu.com>:
>
> > Jagadeesh wrote:
>
> >> Hi,
> >> I am looking for something similar to join in perl. I am doing
> >> [sample perl code]
>
> >> $CMD =3D join(' =A0', =A0$cmd, $arg1, $arg2, $arg3);
>
> > Not 100% sure of what you need, but I think this will do the job for yo=
u:
> > str =3D [cmd, arg1, arg2, arg3].join(' ')
>
> Alternative approaches:
>
> str =3D "#{cmd} #{arg1} #{arg2} #{arg3}"
> str =3D sprintf '%s %s %s %s', cmd, arg1, arg2, arg3

Robert,
I love this approach. It makes my code more readable. Will use it.
Thanks

>
> 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 endhttp://blog.rubybestp=
ractices.com/