Hi Jonathan -

> Can anyone offer me some pointers (pun intended) on how to implement a
> stack in Perl with an array?

This is a basic Perl question, not a mod_perl question, so you might want
to read up in "Programming Perl" or "Learning Perl".  But the thing you
want to look at is "splice".  For your example:

# Start with this:
my @a = ( 'e1', 'e2', 'e3' );

> 0 - e1
> 1 - e2
> 2 - e3

# Starting at index 1, remove 0 elements, and insert 'e4':
splice( @a, 1, 0, 'e4');

> 0 - e1
> 1 - e4
> 2 - e2
> 3 - e3

# Starting at index 2, remove 1 elements, and don't insert anything:
splice( @a, 2, 1);

> 0 - e1
> 1 - e4
> 3 - e3



HTH,
Larry Leszczynski
[EMAIL PROTECTED]

Reply via email to