Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl (http://www.velocityreviews.com/forums/f17-perl.html)
-   -   Array to strings? (http://www.velocityreviews.com/forums/t25530-array-to-strings.html)

gfs X 03-23-2005 09:34 AM

Array to strings?
 
Hi, Im a complete noob to perl.
Is there a way to convert array values into a string?

For example

@myarr=("Sample","test","Array");
My desired output: "SampletestArray"
To then work with as a string.

I know I could just specify piece by piece but thats just too much and
very impractical (im using it to generate filenames)

Much thanks in advance


pingu 03-23-2005 10:44 AM

Re: Array to strings?
 
gfs X wrote:
> Hi, Im a complete noob to perl.
> Is there a way to convert array values into a string?
>
> For example
>
> @myarr=("Sample","test","Array");
> My desired output: "SampletestArray"
> To then work with as a string.
>
> I know I could just specify piece by piece but thats just too much and
> very impractical (im using it to generate filenames)
>
> Much thanks in advance
>

see

perldoc perlfunc
look for 'join'

$string = join('',@myarr)

FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future
for general Perl questions.

gfs X 03-24-2005 01:34 AM

Re: Array to strings?
 
On 2005-03-23 05:44:28 -0500, pingu <pingu@work.bcol.be> said:

> gfs X wrote:
>> Hi, Im a complete noob to perl.
>> Is there a way to convert array values into a string?
>>
>> For example
>>
>> @myarr=("Sample","test","Array");
>> My desired output: "SampletestArray"
>> To then work with as a string.
>>
>> I know I could just specify piece by piece but thats just too much and
>> very impractical (im using it to generate filenames)
>>
>> Much thanks in advance
>>

> see
>
> perldoc perlfunc
> look for 'join'
>
> $string = join('',@myarr)
>
> FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future
> for general Perl questions.


Pingu, that worked perfectly, Thanks a lot! Ill be sure to move to the
other group if i have another question.



All times are GMT. The time now is 02:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.