I am having trouble getting the values from a set of radio buttons. I need to read the values from a radio button groups choices and do pattern matching to make a decision on which radio button to select before submitting a form. I am able to select the input from the form representing the radio buttons and when I use Dumper to show the object it looks like this:
$VAR1 = bless( { 'type' => 'radio', 'menu' => [ { 'value' => 'file-20150610220001.zip', 'name' => '' }, { 'value' => 'file-20150611050002.zip', 'name' => '' }, { 'value' => 'file-20150610220001.zip', 'name' => '' } ], 'name' => 'FileName', '/' => '/' }, 'HTML::Form::ListInput' );
The problem I am having is when I try to access the properties of the object I am not getting what I expect. I have printed the Dumper output of the $input->{menu}[0] hash and expected to see the contents of the Hash, what I got is the following:
$VAR1 = 'HASH(0x7fd53685e830)'; $VAR2 = undef;
The following is an example of the code I have tried using that does not work and I can not find an example of code that reads through all the values in a radio button group.
for my $input ($form->inputs) { if (q{FileName} eq $input->{name}){ print Dumper($input); # Show First output block my %hash =$input->{menu}[0]; print Dumper(%hash); # Show Second output block #Here iterate the radio button values so I can select the butt +on representing the file with the newest date. #for( this is where I am getting stumped) # do work! #} } }
Any help would be appreciated as I can not seem to find any examples that read the values, all examples I can find show how to set values when you know for certain what the value choices will be in advance which is not applicable in my case. Thanks in advance!
In reply to HTML::Form and reading radio button values by aikiPupil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |