On 11/07/2016 10:55 PM, derr...@thecopes.me wrote:
I have an object that I am receiving from LWP::UserAgent::Post
that looks like the below, there is more but this is the important part. Am I
correct in saying this is an array of hashes in a hash? I want to get some of
the values of the 0 element of 'items'. I tried
$$hash_ref{'items'}[0]{'content'} to get 'Practice pilates' but I got an error.
Experimental keys on scalar is now forbidden at todoist.pl line 79.
Am I on the right track? I am just learning about dereferencing now as I go
through the intermediate perl book. I tried adding curling braces in different
places but so far nothing works.
Thanks for any help
Derrick Cope
$VAR1 = \{
you should also post the code used to call data::dumper. the odd thing
above is the \{ which means you dumped a scalar reference to a hash ref.
that may not be what you are expecting.
you may have added the extra ref in your dumping or don't see how to
dereference it back.
if that dump is accurate you first need to get the hash reference out of
the scalar reference:
${$sref}
then you can access items but you need to use -> to be clearer:
${$sref}->{items}
the rest is as you show (but i didn't test it).
in general don't use the $$foo method of dereferencing. always use ->
when possible and i always use {} for dereferencing single things to
make it clear.
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/