Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: CGI.pm popup_menu labels bug?

by Thelonius (Priest)
on Mar 26, 2006 at 17:21 UTC ( [id://539298]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI.pm popup_menu labels bug?
in thread CGI.pm popup_menu labels bug?

Errto has got it, I think!
#!perl -w use CGI::Util qw(rearrange); sub showval { return defined($_[0])?$_[0]:"<undef>" } sub testcall { my (@p) = @_; my($name,$values,$default,$labels,$attributes,$override,$tabindex, +@other) = rearrange([NAME,[VALUES,VALUE],[DEFAULT,DEFAULTS],LABELS, ATTRIBUTES,[OVERRIDE,FORCE],TABINDEX],@p); print "name = ", showval($name), "\n"; print "values = ", showval($values), "\n"; print "labels = ", showval($labels), "\n"; print "attributes = ", showval($attributes), "\n"; print "override = ", showval($override), "\n"; print "tabindex = ", showval($tabindex), "\n"; print "\@other = ", join(" ", @other), "\n"; } sub vooba { my @result = ("foo", "bar"); print "vooba: wantarray = ", wantarray, "\n"; return @result; } sub emptylist { my @result = (); return @result; } print "testcall1\n"; testcall( -name => "nameparm", -values => [ "array" ], -labels => "labels", -default => vooba(), ); print "\ntestcall2\n"; testcall( -name => "nameparm", -values => [ "array" ], -default => vooba(), -labels => "labels", ); print "\ntestcall3\n"; testcall( -name => "nameparm", -values => [ "array" ], -default => emptylist(), -labels => "labels", ); __END__
Output:
testcall1 vooba: wantarray = 1 name = nameparm values = ARRAY(0x225848) labels = labels attributes = <undef> override = <undef> tabindex = <undef> @other = bar testcall2 vooba: wantarray = 1 name = nameparm values = ARRAY(0x225848) labels = <undef> attributes = <undef> override = <undef> tabindex = <undef> @other = bar="-labels" testcall3 name = nameparm values = ARRAY(0x225848) labels = <undef> attributes = <undef> override = <undef> tabindex = <undef> @other =

Replies are listed 'Best First'.
Re^3: CGI.pm popup_menu labels bug?
by blogical (Pilgrim) on Mar 26, 2006 at 18:38 UTC
    Dead on guys. *sigh* Fixed with a simple scalar($_[0]->value)

    "One is enough. If you are acquainted with the principle, what do you care for the myriad instances and applications?"
    - Henry David Thoreau, Walden

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://539298]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2025-06-12 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.