On Sat, 23 Nov 2002, Jonathan M. Hollin wrote:
> Can anyone offer me some pointers (pun intended) on how to implement a
> stack in Perl with an array?
The description you give does not describe an 'academic' stack...
You would probably need to read some good Perl books. I suggest
the "classical"
Tim Tompkins wrote:
But push()ing and pop()ing is not what the original poster wants to do. He
wants to splice(). It doesn't matter if he's talking about treating a stack
in the traditional sense, and it doesn't matter that splice is not as
efficient as push or pop. What matters is that he know
But push()ing and pop()ing is not what the original poster wants to do. He
wants to splice(). It doesn't matter if he's talking about treating a stack
in the traditional sense, and it doesn't matter that splice is not as
efficient as push or pop. What matters is that he knows how to accomplish
w
Tim Tompkins wrote to Ben Mathews:
> Honestly, I didn't see where any of those libs would assist what the
> poster wanted to accomplish. What's wrong with splice?
For implementing a traditional stack, the splice operation (or any
operation which has to rearrange the list every time an element is
Jonathan M. Hollin wrote to [EMAIL PROTECTED]:
> Can anyone offer me some pointers (pun intended) on how to implement
> a stack in Perl with an array?
Perl has two simple builtin functions for treating an array like a
stack. See push() and pop().
Basically:
my @stack;
push @stack, "e3";
push
ack&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
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
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
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 -