Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Saturday, January 28, 2012

Perl array insert

To insert an array @b before position n in an array a, use

splice(@a, n, 0, @b);

(ie 'replace 0 elements of @a, starting at offset n, with the elements of @b').

splice always puts into the list all the elements that it's given. If you tell it to replace fewer elements than it's given, the remaining elements are inserted. In this example, no elements are replaced and all elements are inserted.

Followers

Blog Archive