Hi,
You can use built-in functions push and pop on arrays to get the behaviour of a stack.
The following code may help you
my @stack; #its an array
#push some elements
push @stack,1;
push @stack,2;
#get the length of the stack
$len=$#stack+1;
#pop the elements
for ($i=0;$i<$len;$i++) {...