in reply to "Good" style for splicing arrays

The first is better.

In second case you may have some undef values in the last chunk. It is not good. If you chose nonspace delimeter for elements you'll see that.

Replies are listed 'Best First'.
Re^2: "Good" style for splicing arrays
by LanX (Saint) on Nov 14, 2008 at 12:54 UTC
    Good point, so the second technique must be combined with a definde grep if undefined values matter...

    Thx! 8 )

    ---
    Which song? ;)
      But if you have relevant undefs in your array, things go south. That is why splice is better than the other thing... and it's shorter and so, even more perl-y.
      []s, HTH, Massa (κς,πμ,πλ)

        Good point, Massa! I agree that grepping for defined is no general fix of the problem!

        But in cases you really need to get undefs, the listflattening approach is better.

        e.g. parameter passing  ($self,$x,$y,@opt)=@_;

        so the two approaches are actually not two ways to do the same thing, but two different thing which only seemed interchangebal.

        ---
        Which song? ;)