in reply to Re: Initializing Hashes of Hashes (of Hashes)
in thread Initializing Hashes of Hashes (of Hashes)

Re: compiling - I guess I took line breaking literally.

Re: my solution - Posted in reply to myself later

Re: overwriting - It breaks, yes, but the input is validated at a lower level. It does leave me open to typo bugs

Re: bad strategy - maybe, convince me...

Re: how could a user possibly cause "not a HASH ref" error -
The situation I had in mind was a query like 'a=1&a=2&a.b=3'

where an implementation may build { a => [1,2] } then try to set $args->{a}{b}=3
perl -de1 DB<1> $args = {a => [1,2]} DB<2> $args->{a}{b} = 3 Can't coerce array into hash at (eval 4)[/usr/share/perl/5.6.1/perl5db.pl:1521] line 2.
I did get the error type wrong though.

Replies are listed 'Best First'.
Re: Re: Re: Initializing Hashes of Hashes (of Hashes)
by PodMaster (Abbot) on Apr 29, 2003 at 05:23 UTC
    The situation I had in mind was a query like 'a=1&a=2&a.b=3' where an implementation may build { a => [1,2] } then try to set $args->{a}{b}=3
    That's why functions like ref and exists exist ;D Test and make a decision (clobber or skip).

    I would try to convince you this is bad strategy, but first you must list the reasons you want such a datastructure.
    It might not be bad strategy, but from where i'm standing it doesn't look that way.
    What you really need to do is fully define what should happen (basically draft up a full spec), so things like "not a HASH ref" are not an issue.

    Actually, nevermind the reasons you want this, just complete the spec (a detailed description of design criteria), and you should be fine (given that you implement it correctly ;D).


    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.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.