Bug#551499: CGI::FormBuilder::Field options method returns array reference in array context

Joey Hess joeyh at debian.org
Sun Oct 18 17:29:39 UTC 2009


Package: libcgi-formbuilder-perl
Version: 3.05.01-7
Severity: normal

(You'll probably want to forward this upstream.)

Consider this code, given a $form that has a field named "select"
that is a select list, with one choice in it:

foreach my $field ($form->field) {
	if ($field eq "select") {
		my @options=$field->options;
		print "@options ";
		my $options=$field->options;
		print "$options\n";
	}
}

This prints "ARRAY(XXXX) 1". CGI::FormBuilder::Field's documentation says:

           my @o = $f->options;      # options, aligned and sorted

Which *seems* clear -- the options method, in array context returns an
array. (And as we see above, in scalar context, returns the number of
options.) But it took the concept of returning an array a bit too far,
returning an array *reference*.

I have not checked, but I have a suspicion this used to return a list,
not an array reference, in some older version. Most likely, the bug
was introduced when this line of code was added:

    @opt = optsort($self->sortopts, @opt) if $self->sortopts;

The sortopts method is what returns the array reference, which is then
shoved into a list, and returned.

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libcgi-formbuilder-perl depends on:
ii  perl                          5.10.1-5   Larry Wall's Practical Extraction 

Versions of packages libcgi-formbuilder-perl recommends:
ii  libhtml-parser-perl           3.62-1     collection of modules that parse H

Versions of packages libcgi-formbuilder-perl suggests:
ii  libcgi-session-perl           4.41-1     persistent session data in CGI app
ii  libhtml-template-perl         2.9-1      HTML::Template : A module for usin
pn  libtemplate-perl              <none>     (no description available)
ii  libtext-template-perl         1.45-1     Text::Template perl module

-- no debconf information

-- 
see shy jo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-perl-maintainers/attachments/20091018/08bcf0f9/attachment-0001.pgp>


More information about the pkg-perl-maintainers mailing list