Try using Data::Dumper to see what the hash contains:

use Data::Dumper; ... print Dumper $tmp;

Then, when you know its keys, you can say something like

my $value = $tmp->{key};

Update: err wait, I overlooked that it's a Win32::IEAutomation::Element object... That means, the proper way would be to check the docs or the source for what methods that type of object provides, and then call the respective method which would give you the desired value.

Update2: actually, AFAICT, there is no ready made method for returning the selected item (only to set it), but the following might work (from a quick inspection of the source — I don't have Windows here to try):

sub getSelectedItem { my $elem = shift; my $options = $elem->{element}->options; for (my $n = 0; $n < $options->length; $n++) { if ($options->item($n)->selected) { return $options->item($n)->innerText; } } return undef; } my $selected_value = getSelectedItem($tmp);

(with multiple selections, this would return the first selected item, but you could of course easily modify it to return all selected items as an array or list)


In reply to Re: printing value of HASH reference by almut
in thread printing valur of HASH reference by esmadmin

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.