Steve Sotis wrote:
> I'm using the following, thanks to the input of some on this list:
> 
> foreach $KEY ($query->param())
> {
>       $VARNAME = uc($KEY);
>       @$VARNAME = $query->param($KEY);
>       $$VARNAME = join(",",@$VARNAME);
> }

You evil person, you're using soft references.

> This works fine except in one case I have come across. If 
> $KEY begins with 1 through 9, I get
> 
> Modification of a read-only value attempted at the $$VARNAME 
> = join() line

And now it's biting you. If $KEY is '2', then the assignment to $$VARNAME is
trying to assign to $2, which is a match variable and is read-only.

> If $KEY begins with a zero or any other character (I really 
> didn't try ALL others), it works fine.

Because you're allowed to change the name of your script ($0) and of course
allowed to assign to variables that start with a letter.

> Anything I can do about this?

Use a hash, for example:

    foreach $key ($query->param())
    {
        $uckey = uc($key);
        @{$hash{$uckey}{'ARRAY'}} = $query->param($key);
        $hash{$uckey}{'SCALAR'}   = join(",",@{$hash{$uckey}{'ARRAY'}});
    }

Now you can access e.g. $hash{'BASKETITEM'}{'ARRAY'}[2] for the third
element of the array if it's an array, or $hash{'USERID'}{'SCALAR'} for the
entire string if it's a scalar. Or you can use %arrayhash and %scalarhash if
you don't want the {'ARRAY'} bit.

Cheers,
Philip
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to