in reply to inserting elements in an array

Look at perldoc -f splice

Here is an example

sub strict; my @a1 = qw|a b c d e f|; splice @a1, 3, 0, 'x', 'y', 'z'; print join(',', @a1); print "\n";

Returns:

a,b,c,x,y,z,d,e,f

"Look, Shiny Things!" is not a better business strategy than compatibility and reuse.

Replies are listed 'Best First'.
Re^2: inserting elements in an array
by Xenograg (Scribe) on Feb 02, 2005 at 23:51 UTC

    I learned about splice() while examining the Games::Card module. I did not need the full power of that module but did want the "pick a card, any card" functionality.

    --- The harder I work, the luckier I get.

      Right, but splice is a core part of the Perl language, not an external module nor some function of an external module. It's described in perlfunc.


      Dave