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

Thanks! I am trying to loop through the array ref but I am can't to able to. Am I missing something? My code:
foreach my $td (\@tds) { say $td; }
My output:
ARRAY(0x2ae4b40)

Replies are listed 'Best First'.
Re^5: duplicate table with HTML::TreeBuilder look_down method
by kcott (Archbishop) on May 15, 2015 at 05:35 UTC
    "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

      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)