How to concatenate elements of an array in Perl?

Posted on 2011-09-27
Last Modified: 2012-05-12
Let's say, I have an array. I would like to concatenate the elements of this array (the elements can be all string or integer) with a comma between them. and then assign it to a variable.

@myArray = [temp1 temp 2 temp3]

$String = temp1,temp2, temp3

Open in new window


Question by:Tolgar
1 Comment
LVL 84

Accepted Solution

ozo earned 500 total points
ID: 36711110
@myArray = qw(temp1 temp 2 temp3);
$string = join ',', @myArray;

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
crawling gofundme 4 132
stftime format 4 56
iSeries PERL Scripts 7 171
To run CGI/perl on tomcat and connect to oracle database. 5 136
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question