|
Posted by Ben Morrow on March 14, 2008, 7:38 am
Please log in for more thread options
> venkatesh.naughty@gmail.com wrote:
> > How to assign array variable to a scalar retaining the content of the
> > array in the scalar variable not number of elements ;
> > eg:
> > @array=;
> > $x=@array;
> > I dont want $x to store 2
> > instead to store hi venkatesh
>
> $x = join ' ', %{ $array[0] };
>
> If you rather mean that you have the array
>
> @array = ("hi","venkatesh");
>
> you can simply do
>
> $x = "@array";
...but be careful about $". Either of
{
local $" = ' ';
$x = "@array";
}
or
$x = join ' ', @array;
would be safer.
Ben
|