in reply to Re^2: array pop
in thread array pop

Your questions are a little vague, but maybe this will help:

#! perl use strict; use warnings; my @array = ('a' .. 'e'); print 'Original @array contents: ', join(', ', @array), "\n"; my @popped; unshift @popped, pop @array for 1 .. 3; print '@array now contains: ', join(', ', @array), "\n"; print 'The deleted elements: ', join(', ', @popped), "\n";

Output:

Original @array contents: a, b, c, d, e @array now contains: a, b The deleted elements: c, d, e

See also Data: Arrays.

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re^4: array pop
by GrandFather (Saint) on Sep 11, 2012 at 05:24 UTC

    or more clearly, concisely and efficiently:

    #! perl use strict; use warnings; my @array = ('a' .. 'e'); print 'Original @array contents: ', join(', ', @array), "\n"; my @popped = splice @array, 0, 3; print '@array now contains: ', join(', ', @array), "\n"; print 'The deleted elements: ', join(', ', @popped), "\n";

    splice is your friend.

    True laziness is hard work