Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Twitter API - Not a hash reference

by Discipulus (Monsignor)
on Mar 08, 2018 at 20:25 UTC ( #1210531=note: print w/replies, xml ) Need Help??


in reply to Twitter API - Not a hash reference

Hello,

Just seeing docs (never twitted inmy life..) I assume $nt->lookup_users.. returns an array so you need to iterate over element or access directly one as in:

# totally untested! my @users = $nt->lookup_users; foreach my $usr (@users){ print $usr{screen_name}; #?? use Data:Dump dd method to see the structure you get back (better t +han Data::Dumper) dd $usr } # or directly first element returned print $users[0]{screen_name}; dd $users[0];

I just looked here and here

UPDATE sorry the method does not returns an array but an array ref: not big difference but different..

# totally untested! again my $users = $nt->lookup_users; foreach my $usr (@$users){ print $usr{screen_name}; #?? use Data:Dump dd method to see the structure you get back (better t +han Data::Dumper) dd $usr } # or directly first element returned print $$users[0]->{screen_name}; dd $$users[0];

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Twitter API - Not a hash reference
by Anonymous Monk on Mar 08, 2018 at 20:38 UTC
    This works, thanks! And Data::Dump help me figure out how get to the latest tweet also :) Very helpful.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210531]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-06-21 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (118 votes). Check out past polls.

    Notices?