vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:

Why there is no memory allocation function in perl ?

Replies are listed 'Best First'.
Re: Memory allocation functions
by moritz (Cardinal) on Feb 02, 2009 at 10:33 UTC
    Because memory allocation and freeing is handled by perl automatically for you.
Re: Memory allocation functions
by cdarke (Prior) on Feb 02, 2009 at 12:34 UTC
    There is! You can get memory as a scalar, an array, or a hash. Like so:
    my $scalar; my @array; my %hash;
    That memory is dynamic and managed by perl itself, so you don't need to remember to free it (usually) and you don't need to remember how much memory to allocate. Great isn't it!
      Yes, for sure. But please keep in mind that in case of complex data structures some circular references are not detected properly. In this case memory will still remain allocated.
Re: Memory allocation functions
by Lawliet (Curate) on Feb 03, 2009 at 00:59 UTC

    Who wants to worry about allocating memory when there are bigger problems to handle? As others have already stated, Perl does the allocating for you. This lets you think about the logic of the program and such.

    And you didn't even know bears could type.