in reply to Edit page with checkboxes

I think CGI.pm could do it for you, it has parameters to auto-fill in submitted values (not only checkboxes). You should read the documentation for it.

But just focusing on your code, you could simplify it a lot. First, use a subroutine. (Note that the description for a checkbox should follow the checkbox, but I made it fit your code)

sub checkbox { my ($name, $value, $sel) = @_; my $checked = ($value eq $sel) ? "checked" : ""; print <<EOT $value: <input type="checkbox" $checked name="$name" value="$value">&nbsp;&nbsp; EOT return ($value eq $sel); }

This way, you can write your first two if statements like this:

checkbox("ss", "ss", $ss); checkbox("ss", "ssd", $ss);

Next, you could replace the first three if statements by

my $found = 0; CHECKBOX: foreach (ss ssd pers) { if (checkbox("ss", $_, $ss)) { $found++; last CHECKBOX; } } if (not $found) { # code for those checkboxes with special treatment }

Of course, the code could be more simplified, but I leave that as an exercise to the reader. ;-) (No, actually, you will have to do it yourself because I don't know your problem.)