my $ans = 1; # or whatever. while ($ans) { %pickme = ( n => 1 ); #yes, this should be outside the while. So sue me ;-) $ans = $mech->select( 'server', \%pickme ); if ($ans) { $inputobj = $mech->current_form()->find_input( 'remove', 'submit'); die 'argh! Cannot find delete button on the iSCSI Access page!' unless $inputobj; $ans = $mech->click_button( input => $inputobj ); } } print "Done! Now, accept the empty list\n"; # ok, now accept a (hopefully) empty list of allowed accessors $inputobj = $mech->current_form()->find_input( 'accept', 'submit'); die 'argh! Cannot find Accept button on the iSCSI Access page!' unless $inputobj; $ans = $mech->click_button( input => $inputobj ); #### #### while ($ans) { %pickme = ( n => 2 ); eval { $ans = $mech->select( 'server', \%pickme ); }; if ($ans eq 1) { $inputobj = $mech->current_form()->find_input( 'remove', 'submit'); die 'argh! Cannot find delete button on the iSCSI Access page!' unless $inputobj; $ans = $mech->click_button( input => $inputobj ); } else { $ans = 0; } } %pickme = ( n => 1 ); $ans = $mech->select( 'server', \%pickme ); $inputobj = $mech->current_form()->find_input( 'remove', 'submit'); die 'argh! Cannot find delete button on the iSCSI Access page!' unless $inputobj; $ans = $mech->click_button( input => $inputobj ); print "Done! Now, accept the empty list\n"; # ok, now accept a (hopefully) empty list of allowed accessors $inputobj = $mech->current_form()->find_input( 'accept', 'submit'); die 'argh! Cannot find Accept button on the iSCSI Access page!' unless $inputobj; $ans = $mech->click_button( input => $inputobj ); #### for (@{$self->{menu}}) { if ((defined($val) && defined($_->{value}) && $val eq $_->{value}) || (!defined($val) && !defined($_->{value})) ) { $cur = $i; $disabled = $_->{disabled}; last unless $disabled; } $i++; }