Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: duplicate table with HTML::TreeBuilder look_down method

by kcott (Archbishop)
on May 15, 2015 at 05:35 UTC ( [id://1126731]=note: print w/replies, xml ) Need Help??


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!)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1126731]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-18 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found