rsteinke has asked for the wisdom of the Perl Monks concerning the following question:

The perlapi man page says that hv_store() returns NULL if the operation failed. Aside from passing bad arguments, and system limits like running out of memory, what could cause a failure?

Ron Steinke rsteinke@w-link.net

Replies are listed 'Best First'.
Re: When does hv_store() fail?
by samtregar (Abbot) on Jul 13, 2002 at 06:34 UTC
    Luke, use the source. Looking in hv.c I see the following possible causes for a NULL return:

    • passing a NULL HV * arg
    • needs_copy && !xhv->xhv_array && !needs_store (no, I don't know what this means)

    Notice that only a bad HV * arg will cause a 0 return and running out of memory won't - the program will just croak() with an Out of Memory error.

    -sam