Solved

Join

Posted on 2000-04-23
3
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…

752 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