Hi,
Yes, I was using a ref with my dumper. When i don't do that I don't get $VAR1 =
\{ .
I am still getting an error when I dereference.
my $name = ${$hash_ref_decode}->{items}[0]{content};
say '$name'. $name;
The error is:
Not a SCALAR reference at todoist.pl line 79.
but it should be a scalar right? Am i missing something? When I dump the
$hash_ref I get:
$VAR1 = {
'temp_id_mapping' => {},
'reminders' => [],
'day_orders' => {
'62650309' => 2,
'65024510' => 1,
'65031243' => 3,
'64426670' => 1,
'59893732' => 0,
'62220067' => 2,
'63987563' => 2,
'62650223' => 1,
'62037130' => 1,
'61447674' => 1,
'62344326' => 3,
'60560853' => 1,
'65026440' => 2,
'62220110' => 3,
'59893724' => 1,
'62426193' => 4,
'61838136' => 1,
'61536667' => 1,
'62244426' => 2
},
'collaborators' => [],
'project_notes' => [],
'labels' => [],
'projects' => [
{
'has_more_notes' => bless( do{\(my $o = 0)},
'JSON::PP::Boolean' ),
'is_archived' => 0,
'shared' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'item_order' => 0,
'collapsed' => 0,
'inbox_project' => bless( do{\(my $o = 1)},
'JSON::PP::Boolean' ),
'name' => 'Inbox',
'color' => 7,
'parent_id' => undef,
'indent' => 1,
'is_deleted' => 0,
'id' => 182640304
},
{
'color' => 8,
'parent_id' => undef,
'indent' => 1,
'is_deleted' => 0,
'id' => 182640305,
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'is_archived' => 0,
'shared' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'item_order' => 1,
'name' => 'Personal',
'collapsed' => 0
},
{
'id' => 183055698,
'color' => 7,
'parent_id' => undef,
'is_deleted' => 0,
'indent' => 1,
'item_order' => 2,
'shared' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'collapsed' => 0,
'name' => 'Education',
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'is_archived' => 0
},
{
'is_deleted' => 0,
'indent' => 1,
'color' => 7,
'parent_id' => undef,
'id' => 184048867,
'is_archived' => 0,
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'item_order' => 3,
'shared' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'name' => 'Studio',
'collapsed' => 0
}
],
'collaborator_states' => [],
'notes' => [],
'items' => [
{
'day_order' => 0,
'date_added' => 'Sat 08 Oct 2016 04:53:27 +0000',
'priority' => 1,
'content' => 'Practice pilates',
'date_string' => 'every day',
'responsible_uid' => undef,
'is_archived' => 0,
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'id' => 59893732,
'indent' => 1,
'is_deleted' => 0,
'all_day' => $VAR1->{'projects'}[0]{'inbox_project'},
'parent_id' => undef,
'item_order' => 1,
'collapsed' => 0,
'project_id' => 182640305,
'due_date_utc' => 'Wed 09 Nov 2016 15:59:59 +0000',
'sync_id' => undef,
'assigned_by_uid' => 9494206,
'labels' => [],
'date_lang' => 'en',
'in_history' => 0,
'checked' => 0,
'user_id' => 9494206
},
{
'priority' => 4,
'date_added' => 'Fri 21 Oct 2016 02:10:29 +0000',
'day_order' => 1,
'is_archived' => 0,
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'date_string' => 'Nov 9',
'content' => 'Add neuro development pic to class
design mat1',
'responsible_uid' => undef,
'is_deleted' => 0,
'indent' => 1,
'parent_id' => undef,
'all_day' => $VAR1->{'projects'}[0]{'inbox_project'},
'id' => 62037130,
'in_history' => 0,
'date_lang' => 'en',
'labels' => [],
'assigned_by_uid' => undef,
'checked' => 0,
'user_id' => 9494206,
'collapsed' => 0,
'item_order' => 4,
'sync_id' => undef,
'due_date_utc' => 'Wed 09 Nov 2016 15:59:59 +0000',
'project_id' => 183055698
},
{
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'is_archived' => 0,
'responsible_uid' => undef,
'date_string' => 'Nov 9',
'content' => 'Design billboard',
'priority' => 1,
'date_added' => 'Tue 08 Nov 2016 00:33:14 +0000',
'day_order' => -1,
'checked' => 0,
'user_id' => 9494206,
'in_history' => 0,
'date_lang' => 'en',
'assigned_by_uid' => undef,
'labels' => [],
'sync_id' => undef,
'project_id' => 184048867,
'due_date_utc' => 'Wed 09 Nov 2016 15:59:59 +0000',
'collapsed' => 0,
'item_order' => 1,
'parent_id' => undef,
'all_day' => $VAR1->{'projects'}[0]{'inbox_project'},
'is_deleted' => 0,
'indent' => 1,
'id' => 65014252
},
{
'priority' => 1,
'day_order' => 1,
'date_added' => 'Tue 08 Nov 2016 02:14:11 +0000',
'date_string' => 'Nov 8',
'content' => 'look for Suzanne foot video',
'responsible_uid' => undef,
'is_archived' => 0,
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'id' => 65024510,
'is_deleted' => 0,
'indent' => 1,
'parent_id' => undef,
'all_day' => $VAR1->{'projects'}[0]{'inbox_project'},
'collapsed' => 0,
'item_order' => 5,
'sync_id' => undef,
'due_date_utc' => 'Tue 08 Nov 2016 15:59:59 +0000',
'project_id' => 183055698,
'in_history' => 0,
'date_lang' => 'en',
'labels' => [],
'assigned_by_uid' => undef,
'user_id' => 9494206,
'checked' => 0
},
{
'is_archived' => 0,
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'date_string' => 'Nov 8',
'content' => 'Write Andrew about Taiwan course',
'responsible_uid' => undef,
'priority' => 1,
'date_added' => 'Tue 08 Nov 2016 02:39:05 +0000',
'day_order' => 2,
'in_history' => 0,
'date_lang' => 'en',
'labels' => [],
'assigned_by_uid' => undef,
'checked' => 0,
'user_id' => 9494206,
'collapsed' => 0,
'item_order' => 6,
'sync_id' => undef,
'project_id' => 183055698,
'due_date_utc' => 'Tue 08 Nov 2016 15:59:59 +0000',
'is_deleted' => 0,
'indent' => 1,
'parent_id' => undef,
'all_day' => $VAR1->{'projects'}[0]{'inbox_project'},
'id' => 65026440
},
{
'responsible_uid' => undef,
'date_string' => 'Nov 8',
'content' => 'Email Michele about March workshops',
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'is_archived' => 0,
'priority' => 1,
'date_added' => 'Tue 08 Nov 2016 03:39:02 +0000',
'day_order' => 3,
'sync_id' => undef,
'due_date_utc' => 'Tue 08 Nov 2016 15:59:59 +0000',
'project_id' => 183055698,
'collapsed' => 0,
'item_order' => 7,
'checked' => 0,
'user_id' => 9494206,
'date_lang' => 'en',
'in_history' => 0,
'labels' => [],
'assigned_by_uid' => undef,
'id' => 65031243,
'parent_id' => undef,
'all_day' => $VAR1->{'projects'}[0]{'inbox_project'},
'indent' => 1,
'is_deleted' => 0
},
{
'checked' => 0,
'user_id' => 9494206,
'labels' => [],
'assigned_by_uid' => undef,
'in_history' => 0,
'date_lang' => 'en',
'due_date_utc' => 'Wed 09 Nov 2016 15:59:59 +0000',
'project_id' => 184048867,
'sync_id' => undef,
'item_order' => 2,
'collapsed' => 0,
'all_day' => $VAR1->{'projects'}[0]{'inbox_project'},
'parent_id' => undef,
'indent' => 1,
'is_deleted' => 0,
'id' => 65044250,
'has_more_notes' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'is_archived' => 0,
'responsible_uid' => undef,
'content' => 'Take tools to studio fix reformer #',
'date_string' => 'Nov 9',
'date_added' => 'Tue 08 Nov 2016 06:08:24 +0000',
'day_order' => -1,
'priority' => 1
}
],
'full_sync' => $VAR1->{'projects'}[0]{'inbox_project'},
'locations' => [],
'user' => {
'is_biz_admin' =>
$VAR1->{'projects'}[0]{'has_more_notes'},
'full_name' => 'Derrick Cope',
'id' => 9494206,
'mobile_host' => undef,
'next_week' => 1,
'karma' => '1481',
'completed_count' => 46,
'image_id' => undef,
'inbox_project' => 182640304,
'features' => {
'restriction' => 0,
'has_push_reminders' =>
$VAR1->{'projects'}[0]{'inbox_project'},
'beta' => 0
},
'tz_info' => {
'hours' => 8,
'timezone' => 'Asia/Harbin',
'gmt_string' => '+08:00',
'minutes' => 0,
'is_dst' => 0
},
'join_date' => 'Sat 08 Oct 2016 04:50:01 +0000',
'auto_reminder' => 30,
'sort_order' => 0,
'token' => '50f3bdb6015bc0ebbbc112ba79f8ce2139f920c8',
'is_premium' => $VAR1->{'projects'}[0]{'has_more_notes'},
'start_page' => 'overdue, today',
'mobile_number' => undef,
'email' => '[email protected]',
'premium_until' => undef,
'business_account_id' => undef,
'time_format' => 1,
'start_day' => 7,
'theme' => 3,
'date_format' => 1,
'daily_goal' => 5,
'completed_today' => 2,
'karma_trend' => 'up',
'default_reminder' => 'push'
},
'filters' => [
{
'query' => ':to_me:',
'name' => 'Assigned to me',
'id' => 12152323,
'item_order' => 1,
'color' => 12,
'is_deleted' => 0
},
{
'color' => 12,
'is_deleted' => 0,
'query' => ':to_others:',
'id' => 12152324,
'item_order' => 2,
'name' => 'Assigned to others'
},
{
'query' => 'priority 1',
'name' => 'Priority 1',
'item_order' => 3,
'id' => 12152325,
'color' => 6,
'is_deleted' => 0
},
{
'name' => 'Priority 2',
'item_order' => 4,
'id' => 12152326,
'query' => 'priority 2',
'is_deleted' => 0,
'color' => 6
},
{
'is_deleted' => 0,
'color' => 6,
'item_order' => 5,
'id' => 12152327,
'name' => 'Priority 3',
'query' => 'priority 3'
},
{
'color' => 6,
'is_deleted' => 0,
'query' => 'priority 4',
'name' => 'Priority 4',
'item_order' => 6,
'id' => 12152328
},
{
'name' => 'View all',
'item_order' => 7,
'id' => 12152329,
'query' => 'view all',
'is_deleted' => 0,
'color' => 6
},
{
'query' => 'no date',
'item_order' => 8,
'id' => 12152330,
'name' => 'No due date',
'color' => 6,
'is_deleted' => 0
}
],
'live_notifications' => [
{
'notification_type' => 'karma_level',
'is_deleted' => 0,
'id' => 7052811,
'notification_key' => 'karma_level_1',
'created' => 1476757922,
'seq_no' => 9215772664,
'promo_img' =>
'https://d3ptyyxy2at9ui.cloudfront.net/d3c52f082ccbdf395f0970301f82492e.png',
'karma_level' => 1
}
],
'live_notifications_last_read_id' => 0,
'sync_token' =>
'DiX390utL0NLKzTHqZs1x1d4GDVs3zM4xvUKeMjtHP5tMRI6sJnFF1Xa9aXg1JmCShxPpvp_jVQjjh0uScgGse0A6dD0-8hBVG7FXWfX_HfWsjw',
'day_orders_timestamp' => '1478576342.13'
};
On Tue, Nov 08, 2016 at 12:01:04AM -0500, Uri Guttman wrote:
> On 11/07/2016 10:55 PM, [email protected] 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: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
--
Derrick Cope
--from my mutt
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/