[Wellington-pm] A question about scopes
Jacinta Richardson
jarich at perltraining.com.au
Tue Mar 28 14:34:31 PST 2006
Grant McLean wrote:
> I had to do something similar but got away with sticking to published
> APIs like this:
>
> my($form) = $mech->forms;
>
> foreach my $input ($form->inputs) {
> my $name = $input->name || next;
> next unless $input->type eq 'checkbox';
> next unless $name =~ /some_pattern/;
> $input->check;
> }
>
> $mech->submit;
>
> Was your requirement more esoteric?
Probably not. I couldn't find a check method (I presume it belongs to
HTML::Form) and the way that *seemed* obvious from the mech documentation was this:
foreach ( 1 .. 100 ) { # I know in advance that there will be 100
my $value = $mech->value( $name, $_ );
$mech->tick( $name, $value );
}
Except that value() returns undef when the element is not ticked, rather than
the value set in the checkbox, and even if I knew, or could get the values,
tick() doesn't actually work with multiple checkboxes anyway.
But I like your solution. I guess I should have looked at HTML::Form. It's
inspired me to submit a patch, documentation or code I haven't yet decided.
Jacinta
--
("`-''-/").___..--''"`-._ | Jacinta Richardson |
`6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
(_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 |
_..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
(il),-'' (li),' ((!.-' | www.perltraining.com.au |
More information about the Wellington-pm
mailing list