This file is indexed.

/usr/share/doc/libnet-amazon-perl/examples/similar is in libnet-amazon-perl 0.62-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
#!/usr/bin/perl
###########################################
# similar
# Mike Schilli, 2003 (m@perlmeister.com)
# Fetch books that are similar to a book
# and spider Amazon to a depth of 1.
###########################################
use warnings;
use strict;

use Net::Amazon;
use Net::Amazon::Request::ASIN;
use Data::Dumper;

use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);

my $DEPTH = 1;

my $ua = Net::Amazon->new(
    associate_tag => $ENV{AMAZON_ASSOCIATE_TAG},
    token         => $ENV{AMAZON_TOKEN},
    secret_key    => $ENV{AMAZON_SECRET_KEY},
);

$ARGV[0] = "0201360683";
die "usage: $0 asin\n(use 0201360683 as an example)\n" unless defined $ARGV[0];

print "Finding similar items (depth=$DEPTH) for:\n", 
      asin($ARGV[0]), "\n\n";

for(similars($ua, $ARGV[0], $DEPTH)) {
    print $_->title(), "\n";
}

###########################################
sub similars {
###########################################
    my($ua, $asin, $levels, $found) = @_;

    $found = { } unless defined $found;

    my $req = Net::Amazon::Request::ASIN->new(
        asin  => $asin,
        type  => 'heavy',
    );

        # Response is of type Net::Amazon::ASIN::Response
    my $resp = $ua->request($req);

    if($resp->is_error()) {
        warn "Error: ", $resp->message(), "\n";
        return ();
    }

    my @new = ();

    ($found->{$asin}) = $resp->properties();

    return values %$found if $levels < 1;

    my $prod = $resp->xmlref()->{Details}->{SimilarProducts}->{Product};

    unless(defined $prod) {
        warn "$asin doesn't have similar items defined";
        return values %$found;
    }

    my @plist = ($prod);
    @plist = @{$prod} if ref($prod) eq "ARRAY";

    for(@plist) {
        if(!exists $found->{$_}) {
            $found->{$_}++;
            push @new, $_;
        }
    }
 
    for(@new) {
        similars($ua, $_, $levels-1, $found);
    }

    return values %$found;
}

###########################################
sub asin {
###########################################
    my($asin) = @_;

    my $req = Net::Amazon::Request::ASIN->new(
        asin  => $ARGV[0],
    );

   # Response is of type Net::Amazon::ASIN::Response
   my $resp = $ua->request($req);

   if($resp->is_success()) {
       return $resp->as_string();
   } else {
       die("Error: ", $resp->message(), "\n");
   }
}