in reply to Diff between heap and stack

The heap is the global amount of memory allocated to your program. The stack is a special part of the heap, which stores data in the "last in, first out" mode. It's used to store the data currently processed; for instance when entering a block, variables local to that block are allocated to the stack by growing it; the memory is freed from the stack when leaving the block.
The stack is much faster (you have only one available element at the time) to access. None of this is perl-specific, though, and perl inherited its stack and heap from C.

Replies are listed 'Best First'.
Re^2: Diff between heap and stack
by salva (Canon) on Apr 26, 2005 at 11:22 UTC
    and perl inherited its stack and heap from C

    well, really not, perl uses its own stack that is different from the C stack, that is used by the perl interpreter itself (because it's a C program!).

    The stack is much faster (you have only one available element at the time) to access

    this is not true either, in C allocating memory on the stack is much cheaper than in the heap but accessing it is roughly the same. In perl, as it uses its own memory pools to handle allocations, and actually any value is allocated on the heap (the stack only contains pointers) this doesn't apply and stack and heap are more or less equally fast.