Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: splicing two arrays together

by GrandFather (Sage)
on Jan 06, 2012 at 06:22 UTC ( #946533=note: print w/replies, xml ) Need Help??

in reply to Re: splicing two arrays together
in thread splicing two arrays together

This is a trivial variant of one of the three different splice based options I provided. So which of the trivial variations is "the one best way" to do it? How is this "the best way" if preserving the content of @first is desired? What non-artificial context would require the use of split?

Remember an oft quoted virtue of Perl is TIMTOWTDI with the strong implication that there is seldom a "single best solution". Actually even with languages that tout themselves as offering the "one true way" there is seldom a single "best" solution to any problem.

True laziness is hard work

Replies are listed 'Best First'.
Re^3: splicing two arrays together
by Anonymous Monk on Jan 06, 2012 at 08:51 UTC
    Thanks Grandfather for those solutions, the best solution I guest is the one that requires the least amount of typing in any language?

      I'd say the best solution is the one that works correctly, is maintainable and fast enough. Number of lines or characters of code is generally one of the least important criteria. The most important criteria depends a great deal on the purpose of the code.

      True laziness is hard work
      Well, it depends. The best solution might be the one that runs fastest, uses minimal memory, or the one that can be easily understood for later maintenance.
Re^3: splicing two arrays together
by TJPride (Pilgrim) on Jan 06, 2012 at 20:58 UTC
    Actually, it's an independent solution that just happens to be mostly identical to yours. My determination of "best" is that the OP asked for a solution with splice, and this was the best solution possible with splice. Obviously, splice is not the most efficient way to do this overall, but that's the OP's problem, since he framed the question in the context of splice rather than the context of finding the most efficient way to do merge two arrays. I'm guessing it's a homework problem and they said he had to use splice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946533]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2018-06-23 18:54 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.