in reply to Tied HASH as boolean?!

Well I cannot resist a reference to my very first post here on perlmonks:

Whither the truth of a tied hash? (Apr 28, 2000)

The short answer is to use scalar keys %Hash, but I still consider this behavior to be an irritant.

Matt

Replies are listed 'Best First'.
Re: Re: Tied HASH as boolean?!
by gmpassos (Priest) on Jun 10, 2003 at 02:00 UTC
    Thanks!

    But this is just to enable the end user (a Perl programmer) to use that hash as a normal hash in the framework! But it actually don't know when it's tied or not, since I only tie it to can see the keys of 2 different HASHes at the same time.

    Just to know the story. This is for HPL (that I will release for the public soon). When you have POST or GET inputs, they are parsed and stored in the HASHes %POST and %GET (since you can send the both at the same time). But from previous versions this were in the HASH %FORM. Now the HASH %FORM still exists, and is just an alias in the table entry to %POST or %GET, depending of the situation. But when you have the both, %FORM need to have the content of %GET and %POST at the same time, so, I tie it and make it work/look in the 2 HASHes, insted of just copy the content (what is wrong).

    But the user really need to can test if %FORM is true, since this code is very usual to know if you have formulary inouts:

    if ( %FORM ) { ...response... } else { ...show the formulary... }

    Graciliano M. P.
    "The creativity is the expression of the liberty".