in reply to Hash of Hashes

The Dumper routine of Data::Dumper takes a reference, so you'll see the "real" data structure by

print Dumper \%books;

The backslash in 'O\'Reilly Media, Inc.' is in the output to quote the single-quoted string.

Replies are listed 'Best First'.
Re^2: Hash of Hashes
by ewhitt (Scribe) on Mar 09, 2008 at 10:23 UTC
    Wow, the whole time I thought it was the hash statements. Thank you all very much for the insight. In regards to the backslash, are there other options than single quotes? As you can see in my code, it is being returned from the Amazon query.

      There is another way for Data::Dumper to display the results and that is by simply turning on the Useqq flag like this $Data::Dumper::Useqq = 1;, though it is not recommended. This way you'll get double quotes instead of single quotes.

      As a side note, I don't know what you are trying to do with your code, but you may get into trouble if you try to get two books published on the same date. If that happens, from your code, the first book retrieved will get overwritten and you won't know it was ever there. My advice to overcome that situation is to make, for each date, an array of hash references with the other book properties.

      Something like

      if ($response->is_success()) { for my $prop ($response->properties) { my %info; $info{'title'} = $prop->title(); $info{'authors'} = join(", ",$prop->authors()); $info{'isbn'} = $prop->isbn(); $info{'pages'} = $prop->numpages(); $info{'publisher'} = $prop->publisher(); $info{'image_small'} = $prop->ImageUrlSmall(); $info{'image_medium'} = $prop->ImageUrlMedium(); push $books{$prop->publication_date()}, \%info; } print Dumper \%books; }
        Surely a simpler way would be to make the ISBN the key? I don't know much about ISBNs but I'm guessing they're guaranteed unique?


        Nobody says perl looks like line-noise any more
        kids today don't know what line-noise IS ...