starbizcon has asked for the wisdom of the Perl Monks concerning the following question:

I am using $Cgi->popup_menu and reading values from a text file. This worked well until recently on updated cpanel versions (with presumingly updated CGI.pm):
$Cgi->popup_menu("convert_links_to_friendly", \@label, $CONFIG{convert_links_to_friendly}, \%LABEL);
If $CONFIG{convert_links_to_friendly} is 1, it still works well:
<select name="convert_links_to_friendly" > <option selected="selected" value="1">Yes</option> <option value="0">No</option> </select>
however if $CONFIG{convert_links_to_friendly} is 0, now it prints:

<select name="convert_links_to_friendly"> <option value="1">Yes</option> <option value="0">No</option> </select>

while I need it to print (which is still working OK on older servers but not working OK on recently updated cpanel servers since 2-3 months):
<select name="convert_links_to_friendly"> <option value="1">Yes</option> <option selected="selected" value="0">No</option> </select>
Do you have any ideas on what could have caused this behaviour?

Replies are listed 'Best First'.
Re: Problems with recent CGI.pm
by almut (Canon) on Aug 05, 2008 at 15:40 UTC

    It's line 2454 in CGI.pm (v3.39):

    } elsif ($default) {

    which makes $default values of zero (=false) be ignored. ($default is where your $CONFIG{convert_links_to_friendly} value ends up in.)

    The fix would apparently be

    } elsif (defined $default) {

    but I can't tell for sure whether that would maybe break something else (don't think so), or what the motivation for not using defined might have been...