sub click { ... my $input; my $form = $self->current_form; for ($form->inputs) { next unless $_->type =~ /^(?:submit|image)\z/; next if $button && $_->name ne $button; next if $_->disabled; $input = $_; last; } Carp::croak("No clickable input with name $button") if $button && !$input; ... #### next unless $_->type =~ /^(?:submit|image|button)\z/;