Nathan Wiger wrote:
> 1. make a listref only for multiple values:
>    @name = @{$CGI{name}} if ( ref $CGI{name} eq 'ARRAY' );

Ick.  That piece of code is small enough, but it's going to end up
replicating itself everywhere %CGI is accessed.  This will be a fruitful
new source of bugs when people forget to check C<ref $CGI{name}>, and a
maintenance nightmare when someone makes a small like adding "multiple"
to a select tag.

> But I don't think listrefs are needed in all contexts, since you should
> know which elements will likely have multiple values (checkboxes, etc).

Maybe (and I stress maybe) the programmer knows, but the code that
parses into %CGI doesn't know whether a parameter is from a checkbox
group with only one value checked, or something else.

> 2. make it a comma-delimited string:
>    $name = $CGI{name};
>    @name = split ',', $name;
> The problem arises if your data has commas in it.

Double ick.

> Maybe %CGI is tied. Fast embedded tie, like in Perl 6. :-)

It looks to me like FETCH is always called in scalar context.  Even
saying C<@foo{...}> results in multiple scalar fetches.  That could be
changed, I suppose, but it makes me twitch.  Maybe someone who knows
ties better could comment on this.

-- 
Robert Mathews
Software Engineer
Excite@Home

Reply via email to