On Thu, 15 Aug 2019 16:18:57 +0100
James Kerwin <jkerwin2...@gmail.com> wrote:
> I'm currently investigating a data structure that it gives me to see
> what values I can get from it. Through random experimentation I've
> managed to find that it had "title" and "id".
> 
> I wrote this to get the data structure containing the worksheets:
> 
> my @ws = $spreadsheet->worksheets;
[...]
> If I do this:
[...]
> I get:
> 
> { atom=XML::Atom::Entry=HASH(0x1b81928)
> container=Net::Google::Spreadsheets::Spreadsheet=HASH(0x1bbdb80) }
[...]

Right, from that class name it sounds like you're working with
Net::Google::Spreadsheets -
https://metacpan.org/pod/Net::Google::Spreadsheets

Given that you're talking about $spreadsheet->worksheets I assume that
the bit of code you omitted before your example finds the appropriate
spreadsheet using the spreadsheets() / spreadsheet(%cond) methods, so
$spreadsheet will be a Net::Google::Spreadsheets::Spreadsheet object.

Rather than trying to poke around in the guts of the objects you got,
look at the documentation.  The worksheets() method gives you a list of 
Net::Google::Spreadsheets::Worksheet objects, so have a look at the
documentation for that class:

https://metacpan.org/pod/Net::Google::Spreadsheets::Worksheet

For e.g. you'll see that $worksheet->rows will give you a list of rows,
as Net::Google::Spreadsheets::Row objects, so you could then look at
the documentation for that ::Row class:

https://metacpan.org/pod/Net::Google::Spreadsheets::Row

All in all, you're dealing with objects here, so you're better off
looking at their documentation to see what methods they provide rather
than digging around in their guts - both because it should be easier for
you, but also because your code should be cleaner and more robust, and
less likely to break on future updates to the modules you're using.

Most CPAN authors will try to keep the exposed methods they've
documented consistent as far as possible or do deprecations as cleanly
as possible, but if you've been digging around "under the hood" treating
the object as a hashref, that internal implementation may well change
without notice and that's on you.

Cheers

Dave P (BIGPRESH)

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to