Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: appending arrays

by hardburn (Abbot)
on Nov 19, 2003 at 17:29 UTC ( [id://308350]=note: print w/replies, xml ) Need Help??


in reply to Re: appending arrays
in thread appending arrays

That will get the data off the end of @array2, not the beginning. Use shift instead of pop.

Update: Nothing to see here. Move along. (Must read more carefully next time).

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Re: appending arrays
by Not_a_Number (Prior) on Nov 19, 2003 at 20:57 UTC
    That will get the data off the end of @array2, not the beginning.

    Err... Isn't that what the OP wanted? It works fine for me with the OP's data. OK, it destroys @array2, as Abigail-II pointed out. Just for fun, here's a solution that destroys both of the original arrays:

    die "Arrays of different lengths" unless @array1 == @array2; my @array3 = map { shift ( @array1 ) . pop ( @array2 ) } @array1;

    dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://308350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-20 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found