Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::Amazon::ATS (problems printing returned Pseudo-hash)

Status
Not open for further replies.

QoolKidder

Programmer
Jul 29, 2008
2
CA
Hi Everyone,

First post - so thanks in advance for any help.

I am using the Net::Amazon::ATS (to access Amazon topsites) module and I am having a crazy time trying to figure out how to print the results I get form it. Here is the line that calls it the module:

my $data = $ats->topsites(
Start => 100,
Count => 10,
CountryCode => 'US',
);

From the module an array is return : return \@sites (is returned)

Using Dumper to print the results of $data on the return I get the following:

$VAR1 = [
{
'Country' => {
'ViewsPerMillion' => '1.32',
'ReachPerMillion' => '20',
'Rank' => '49997',
'ViewsPerUser' => '5.4'
},
'Rank' => '1111111',
'Domain' => 'xxx.org'
},
{
'Country' => {
'ViewsPerMillion' => '3.18',
'ReachPerMillion' => '16',
'Rank' => '222222',
'ViewsPerUser' => '17'
},
'Rank' => '22222222',
'Domain' => 'booger.com'
}
];


I am looking for a construct that will help me print this out. I have tried just everything I could think of and have scoured the internet everywhere.

What I current have is:
foreach my $site (@{$data->{Country}}) {
my $domain = $site->{domain};
print "Domain" $domain\n";
}

The error I get is "Pseudo-hashes are deprecated at line XX which is the foreach line.

If anyone can lend some assistance it would be GREATLY appreciated.

Thanks in advance.

C
 
try this, not sure it its correct or not, assume the reference to the data is name $data:

Code:
foreach my $site (@{$data}) {
   print $site->{domain},"\n";
}

What it looks like is an array of hashes, so you have to loop through the array @{$data} to get to each hash key.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thanks - that worked awesome ... I got the domain name out easily. Now I am just working on getting the country data out. Thanks so much!

C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top