Subject: | hash is not reset before each() is called |
Very subtle bug / best practice issue that can cause FillInForm to fill
in nothing.
If you call $fif->fill( fdata=>\%some_hash ) and you have previously
done an each(%some_hash) or called Dumper(\%some_hash), FillInForm will
not fill in any of your fields as the pointer that each() uses will
already be at the end of %some_hash -- resulting in nothing being copied
into %copy
The solution is to call keys() on %$fdat before the while loop:
--- HTML/FillInForm.pm 2007-02-15 15:35:49.000000000 -0500
+++ HTML/FillInForm.pm 2007-02-15 15:38:07.000000000 -0500
@@ -41,6 +41,7 @@
if (my $fdat = $option{fdat}){
# Copy the structure to prevent side-effects.
my %copy;
+ keys %$fdat;
while(my($key, $val) = each %$fdat) {
next if exists $ignore_fields{$key};
$copy{ $key } = ref $val eq 'ARRAY' ? [ @$val ] : $val;
Cheers,
spd