foreach my $param ( $cgi->param ) { next if ( $param !~ m/^hidden_(.+)$/ ); my $checkboxname=$1; if ( ! $cgi->param( $checkboxname ) ) { # delete this item } else { # add this item } }