HASHREF in Perl

Posted by Uri on Stack Overflow See other posts from Stack Overflow or by Uri
Published on 2010-05-15T15:47:34Z Indexed on 2010/05/15 15:54 UTC
Read the original article Hit count: 245

Filed under:

I'm trying to decrypt a Perl code which I'm not familiar with, somehow related to HashRef. I'm using Amazon::S3, but my question is a general Perl question. See the code below:

use Amazon::S3; my $s3 = Amazon::S3->new( ... ); my $response = $s3->buckets;

Documentation (here) sais, about s3->buckets: Returns undef on error, else HASHREF of results

The following line is working for me, but I don't understand why:

for $b in ( @ { $response->{buckets} } ) { print "bucket: " . $b->bucket . "\n"; }

I'm buzzled by each operator on the first line.

What type exactly are $response, $respone->{bucket}. Looks like the expression within the 'for' is an array, but I don't understand this syntax: @{ ... }?

© Stack Overflow or respective owner

Related posts about perl