in reply to Re: Salesforce Data Parser
in thread Salesforce Data Parser

Thank you so much!! Haha, I tried so many variations of for, foreach, hash keys, etc. and just could not get it. That worked and it does exactly what I want. Again, thanks so much!

Replies are listed 'Best First'.
Re^3: Salesforce Data Parser
by stevieb (Canon) on Aug 06, 2015 at 16:23 UTC

    You're very welcome, I'm glad it worked.

    A little more info on when you said "is ALMOST an Array of Hashes". When printing with Data::Dumper, you always pass in a reference to the structure you're printing, so if the outermost part of the structure is an array (), it'll automatically get converted to [] in the output as you've passed in a reference to the array. In fact, the API itself returns the array as a reference in the first place, so you wouldn't need to take a reference to it when passing it into Dumper. These are equivalent when referring to Data::Dumper...

    my @array = (1, 2, 3); print Dumper \@array;
    my $aref = [1, 2, 3]; print Dumper $aref;

    So it is really an Array of Hashes (AoH), it just looks a tiny bit different when the outermost part of the structure is a reference. You also need to access and use them slightly differently as well (by using dereference operators).

      So is the dereference operator \@array or the use of ->?

        Take a reference (ie. make $aref a reference of @a):

        my $aref = \@a;

        Extract one element from the array ref by using -> deref operator:

        my $thing = $aref->[0];

        Use the array circumfix operator to dereference the whole array ref at once:

        my @b = @{$aref}; # used in loops, too

        I've proposed part of my reference howto as a tutorial here on PM. It may further help your understanding: Tutorial RFC: Guide to Perl references, Part 1.