in reply to From Array 2 string

The equivalent to your code is, as others have pointed out:

$str = join( '', @arr );

Please read the docs on join. You could also do:

{ local $" = ''; # see perlvar $str = "@arr"; }

Which might be faster. See perlvar. Also check out Data::Dumper - even if its format is not what you want, the code inside might be enlightening with regard to creating string representations of various variable types.

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

Replies are listed 'Best First'.
Re^2: From Array 2 string
by ikegami (Patriarch) on Nov 15, 2005 at 18:41 UTC
    20 words: Rate stringify join stringify 155272/s -- -29% join 219556/s 41% -- 51 words: Rate stringify join stringify 83452/s -- -16% join 99407/s 19% -- 2000 words: Rate stringify join stringify 2736/s -- -3% join 2813/s 3% --

    They're about the same speed, but stringification has a much bigger overhead. Better off with join.

      Errm, what? At a rate of 155272/s, does it even matter for 99.99% of the apps out there? They’re going to be waiting for the harddrive, or the network, or the terminal, or whatever.

      Better off with whichever one is more readable.

      (Which is going to be join most of the time – but recommending it on the basis of performance is plainly silly.)

      Makeshifts last the longest.