Skip Menu |
 

This queue is for tickets about the HTML-Widget CPAN distribution.

Report information
The Basics
Id: 25497
Status: open
Priority: 0/
Queue: HTML-Widget

People
Owner: Nobody in particular
Requestors: jshields-subscriptions [...] mechanicnet.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: In scalar context HTML::Widget::Result::param returns the first element of a parameter arrayref instead of the arrayref itself.
Date: Fri, 16 Mar 2007 11:56:39 -0700
To: bug-HTML-Widget [...] rt.cpan.org
From: John Shields <jshields [...] mechanicnet.com>
Download (untitled) / with headers
text/plain 1.3k
In the method from HTML::Widget::Result below the documentation clearly states that calling the "param" method in scalar context for a multi-valued parameter will return an arrayref to the values. Currently the code returns the first value, not the arrayref itself. The fix is to change line 389 from: : $self->{_params}->{$param}->[0]; to : $self->{_params}->{$param}; Of course, this can be worked around by always using list context... Regards, John =head2 param Arguments: $name Return Value (scalar context): $value or \@values Return Value (list context): @values Returns valid parameters with a CGI.pm-compatible param method. (read-only) =cut sub param { my $self = shift; if ( @_ == 1 ) { my $param = shift; my $valid = $self->valid($param); if ( !$valid || ( !exists $self->{_params}->{$param} ) ) { return wantarray ? () : undef; } if ( ref $self->{_params}->{$param} eq 'ARRAY' ) { return (wantarray) ? @{ $self->{_params}->{$param} } : $self->{_params}->{$param}->[0]; } else { return (wantarray) ? ( $self->{_params}->{$param} ) : $self->{_params}->{$param}; } } return $self->valid; }
Download (untitled) / with headers
text/plain 261b
The method is supposed to be CGI.pm-compatible, so it's the documentation that's wrong, not the code. This isn't likely to get fixed until a new maintainer comes forward, see the note at http://search.cpan.org/~cfranks/HTML-Widget-1.11/lib/HTML/Widget.pm#NOTE


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.