in reply to Re^4: duplicate table with HTML::TreeBuilder look_down method
in thread duplicate table with HTML::TreeBuilder look_down method

"I am trying to loop through the array ref but I am can't to able to. Am I missing something?"

Your problem is looping through an arrayref!

An arrayref is a single scalar. In this case: "ARRAY(0x2ae4b40)".

You probably want to loop through the actual array (@tds), not the arrayref (\@tds).

This will output each element of @tds:

for my $td (@tds) { say $td; }

-- Ken

Replies are listed 'Best First'.
Re^6: duplicate table with HTML::TreeBuilder look_down method
by mazdajai (Novice) on May 15, 2015 at 13:15 UTC
    If I try to loop through the @tds I still get arrayref. Code:
    foreach my $td (@tds) { say $td; }
    Output:
    ARRAY(0x2a70c90) ARRAY(0x2a705b8)

      That is because you are working with a two dimensional array. You are very close, you just need to further dereference the variable $td

      foreach my $td (@tds) { say for @$td; }
      However ... what are you going to do with the results, which are bits of HTML stored as strings?

      You most likely need something more like this:

      Output:

      $VAR1 = [ { 'Actual Start' => undef, 'Node Name' => 'ServerB', 'Results' => undef, 'Schedule Name' => 'DAILYBACKUP_6PM', 'Schedule Start' => '2015-05-11-18.00', 'Domain Name' => 'ST10_DOMAIN', 'Status' => 'Missed' }, { 'Schedule Start' => '2015-05-11-18.00', 'Results' => undef, 'Domain Name' => 'ST13_DOMAIN', 'Schedule Name' => 'NJDLYBACKUP_6PM', 'Status' => 'Missed', 'Node Name' => 'ServerC', 'Actual Start' => undef } ];

      (See emulate Python's range function for more information about the range() function included in the code.)

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      
        It is to extract the class tags with Warning and Error in a very, very long html report and print only the Warning/Errors. Extracting the values and dump them into array is something I had in mind, thanks a lot Jeff!! (And I don't know you can emulate range function!)