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

Posted on 2012-08-22
Last Modified: 2012-08-28
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

Question by:Tolgar
    LVL 31

    Assisted Solution

    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};
    LVL 28

    Accepted Solution

    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

    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.
    LVL 84

    Assisted Solution


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Filtering a file to table 9 96
    perl CPAN issue 3 81
    Migrate OTRS to newest version. 1 295
    ppm conversion to curl on a module install 8 67
    Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now