Solved

Join

Posted on 2000-04-23
3
163 Views
Last Modified: 2010-03-05
I have 2 arrays, with the following data:

Array1
rr
ff
dd
ee

Array2
11
22
33
44

I actually is thinking of using 'join' to join the 2 array together, but like the following:
rr 11 ff 22 dd 33 ee 44

Is it possible?

Thanks
0
Comment
Question by:sata
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
adam923 earned 100 total points
ID: 2742149
join puts one constant item in between each element
you want an "interleave" like this...

@a1 = ('rr', 'ff', 'dd', 'ee');
@a2 = ('11', '22', '33', '44');
@a3 = ();
for($i=0; $i<$#a1; $i++){
   push @a3, $a1[$i], $a2[$i];
}
0
 
LVL 4

Expert Comment

by:adam923
ID: 2742151
sorry... change the
$i<$#a1
to
$i<=$#a1
0
 
LVL 84

Expert Comment

by:ozo
ID: 2742553
@a3 = map{$_,shift @a2} @a1;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

735 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