473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

Jul 19 '05 #1
2 47134
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.
Jul 19 '05 #2
On 2005-03-23 05:44:28 -0500, pingu <pi***@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.

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Sims | last post by:
Hi, Given a string $txt and an array of strings $txt_array what would be the best/fastest way to search in _insensitive_ case if $txt is in $text_array and, if it is, where is it? Because I...
0
by: Linux Inquirer | last post by:
Hi Guys, I need to pass a C structure of this form from VB6 <-> VC++ 6 struct BTag { int rowIndex; BSTR* valueList; } B;
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
3
by: sjonca | last post by:
I have the need to convert from a *ptr to an array. I'm using the getpass(x) function that returns a *ptr. I want this converted to an array in order to concatonate it with 4 other array strings....
10
by: Ian Todd | last post by:
Hi, I am trying to read in a list of data from a file. Each line has a string in its first column. This is what i want to read. I could start by saying char to read in 1000 lines to the array( i...
5
by: Paul | last post by:
Hi, I'm trying to create an array containing the entire contents of a text file and delimit the elements using vbCrLf. The text file is like this.... -text1 -text2 -text3
3
by: snow.carriers | last post by:
Let me first state that I'm using Borland Turbo C++, it's relatively old so the new string methods won't work. Anyways, first I'm trying to collect a line of a string (with numbers, letters,...
2
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be...
10
by: Krustov | last post by:
$rambo="daffy duck"; $rambo="mad max"; $rambo="daffy duck"; $rambo="superman"; etc etc How do i remove duplicate strings from a array ? . ('daffy duck' could appear more than twice in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.