Solved

Join

Posted on 2000-04-23
3
159 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
PERL get the value for query 4 155
Which version of C should I use when Perl is too slow? 13 183
crawling gofundme 4 132
Perl Versus AWK? 7 45
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…

789 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