Don't reinvent the wheel. http://search.cpan.org/search?query=stack&mode=module
Ben > -----Original Message----- > From: Jonathan M. Hollin [mailto:[EMAIL PROTECTED]] > Sent: Saturday, November 23, 2002 6:59 AM > To: [EMAIL PROTECTED] > Subject: [OT] Stack Operation > > Can anyone offer me some pointers (pun intended) on how to implement a > stack in Perl with an array? > > I need to have an array of elements as follows: > > 0 - e1 > 1 - e2 > 2 - e3 > ... > > And I need to be able to insert items: > > e4 needs to go into $array[1]. 1 and 2 need to move down (or up or left > or right - depending on how you visualise arrays) yet retain their > contents: > > 0 - e1 > 1 - e4 > 2 - e2 > 3 - e3 > ... > > And, you guessed it, I need to be able to remove elements, and have the > others move down... > > remove e2, leaving: > > 0 - e1 > 1 - e4 > 3 - e3 > ... > > How do I implement this in code anyone? > > > -- > Jonathan M. Hollin > > Technical Director: Digital-Word Co. (http://digital-word.com/) > Co-ordinator: WYPUG (http://wypug.pm.org/) >