Solved

Join

Posted on 2000-04-23
3
150 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
Comment Utility
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
Comment Utility
sorry... change the
$i<$#a1
to
$i<=$#a1
0
 
LVL 84

Expert Comment

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
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 …
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now