in reply to SDBM_File and complex data structures

No hash can really store complex data structures, they can store references to them, which is why when SDBM_File serializes the data structure, what gets stored as a value instead of a reference is its string value (print [] prints ARRAY(0x225240), but $a="ARRAY(0x225240)"; is not an array reference).
What you should investigate is MLDBM (pay attention to the BUGS ).
it tells me that 'key' is a ref to an array
No it doesn't. `perldoc -f ref'

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: SDBM_File and complex data structures
by muba (Priest) on Oct 10, 2004 at 12:40 UTC
    I see. Ok, I will check MLDBM.

    Indeed, that print statement did not explicitly tell me it was a ref to an array, technically, but I would then like to call it... "ref at first sight" :)

    Well, thank you for your quick reply.




    "2b"||!"2b";$$_="the question"
    Besides that, my code is untested unless stated otherwise.
    *One more: please review the article about regular expressions (do's and don'ts) I'm working on.
Re^2: SDBM_File and complex data structures
by tilly (Archbishop) on Oct 11, 2004 at 16:59 UTC
    MLDBM and SDBM_File is a dangerous combination because the former creates long values out of nested data structure and the latter truncates those, resulting in data loss.

    In this situation I'd recommend a safer solution. Like DBM::Deep.