What is the difference between
$mech -> field($name, $value)
and
$mech -> set_fields($name => $value)
and why do they both exist? It seems like they each set the field named $name to $value.
$mech -> field($name, $value)
field() only lets you set one name at a time. But
$mech -> set_fields($name => $value, $name2 => $value2,... $nameN => $valueN)
...set_fields() allows you to set multiple names at the same time.
That's not really such a big deal because you could always use the first one in a loop:
my @data = (
first => 'A',
last => 'B',
age => 22,
#possibly 100,000 other name/value pairs
);
my($name, $value);
while(@data) {
($name, $value) = splice(@data, 0, 2);
$mech->field($name, $value);
}
...but it's more convenient to write:
$mech->set_fields(@data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With