A common solution in other languages is

        foreach (split on '&')
                key,value = split on '='
                de-escape key
                de-escape value
                push value on end of the array
                        defined by the hash on key

or if you need backward compat us something like

                if exists hash on key and is array
                        push value onto end of array
                else
                if exists hash on key
                        hask on key is array of
                                prev.value, value
                else
                        scalar hash on key = value

of course in java/perl/python/ruby you can do this very nicely with
overloading and little if any 'if's :-)

Dw

On Mon, 7 May 2001, Valerio Gionco wrote:

> We are trying to port a big CGI application written in TCL to mod_dtcl.
> In some cases, the application
> calls a CGI setting the same variable to more than a value, like in this
> example (for a GET):
>
> http://valerio.private/valerio/test.tcl?x=v1&x=v2&x=v3
>
> Internally our code parsed the URL making something equivalent to
>
> set $x "v1|||v2|||v3"
>
> using "|||" as a separator. We patched the source code of mod_dtcl to
> comply with this
> format, and I think something similar (eventually more flexible) should
> be included in the module.
>
> Here is the patch:
>
> $ diff  mod_dtcl.c mod_dtcl.c.orig
> 745,753c745
> <             /* XXX Patch: if the variable is already defined, append
> the new value using "|||" as a separator */
> <
> <           if (Tcl_ObjGetVar2(interp, varsobj,
> STRING_TO_UTF_TO_OBJ(parms[i].key), 0) )
> <                  {
> <                   Tcl_ObjSetVar2(interp, varsobj,
> <                          STRING_TO_UTF_TO_OBJ(parms[i].key),
> <                          STRING_TO_UTF_TO_OBJ("|||"),
> <                          TCL_APPEND_VALUE );
> <                           Tcl_ObjSetVar2(interp, varsobj,
> ---
> >           Tcl_ObjSetVar2(interp, varsobj,
> 756,762c748
> <                          TCL_APPEND_VALUE );
> <                    }
> <           else
> <                   Tcl_ObjSetVar2(interp, varsobj,
> <                          STRING_TO_UTF_TO_OBJ(parms[i].key),
> <                          STRING_TO_UTF_TO_OBJ(parms[i].val),
> <                          0 );
> ---
> >                          0);
>
>
>
>
> Regards,
>
> Valerio Gionco
> MOST s.r.l.
>
> --
> ****************************************************************************
>             "Life's not fair, but the root password helps."
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to