• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

How to get a value from the given hash reference in Perl?

How can I get the value of "row" from the following hash reference?



x $report_href
0  HASH(0x1c917a0)
   'fileTobeChecked' => HASH(0x2077f80)
      '/some/dir/myfile.cpp' => HASH(0x289f750)
         'arrayofmatches' => 1
         'check' => '<font color=#9B9B00>  WARNING: The file type does not exist in the Coding Standards Database</font>'
         'checkListDetailsHtml' => '<br><b>Check 1:</b> <font color=#9B9B00>  WARNING: The file type does not exist in the Coding Standards Database</font><br><td>n/a <br></td></tr><br>'
         'checkListHtml' => '<td width:200px><font color=#9B9B00>  WARNING: The file type does not exist in the Coding Standards Database</font></td><td><a href="file://///some/dir/to/file/myFile.cpp" style="color: black">n/a</a></td></tr>'
         'checkResult' => 'n/a'
         'row' => 1
         'textColor' => 'black'

Open in new window

0
Tolgar
Asked:
Tolgar
3 Solutions
 
farzanjCommented:
print $report_href->{'row'};

Open in new window


I am not exactly sure what are the keys so it will be an iterative process for me.
print keys %{$report_href};
0
 
FishMongerCommented:
I'm not sure at which level 'row is at, but it looks to be either:

print $report_href->{'fileTobeChecked'}{'row'};

Open in new window

or
print $report_href->{'fileTobeChecked'}{'/some/dir/myfile.cpp'}{'row'};

Open in new window


Based on the structure shown in some of your other posts, it's probably the first one.
0
 
ozoCommented:
$report_href->{fileTobeChecked}{'/some/dir/myfile.cpp'}{row}
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now