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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.