Browse - Programming Tips - How do I prepend/append in perl?

Date: 2011aug29
Language: perl

Q.  How do I prepend/append in perl?
(Add at the start of an array, add at the end of an array.)

A. Prepend with unshift() - eg:

my(@a); unshift(@a, 'three'); unshift(@a, 'two'); unshift(@a, 'one');
is the same as @a = qw(one two three) A. Append with push() - eg:
my(@a); push(@a, 'one'); push(@a, 'two'); push(@a, 'three');
is the same as @a = qw(one two three)