/usr/share/doc/libtokyocabinet-perl/examples/tcadbex.pl is in libtokyocabinet-perl 1.34-1build2.
This file is owned by root:root, with mode 0o644.
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 | use TokyoCabinet;
use strict;
use warnings;
# create the object
my $adb = TokyoCabinet::ADB->new();
# open the database
if(!$adb->open("casket.tch")){
printf STDERR ("open error\n");
}
# store records
if(!$adb->put("foo", "hop") ||
!$adb->put("bar", "step") ||
!$adb->put("baz", "jump")){
printf STDERR ("put error\n");
}
# retrieve records
my $value = $adb->get("foo");
if(defined($value)){
printf("%s\n", $value);
} else {
printf STDERR ("get error\n");
}
# traverse records
$adb->iterinit();
while(defined(my $key = $adb->iternext())){
my $value = $adb->get($key);
if(defined($value)){
printf("%s:%s\n", $key, $value);
}
}
# close the database
if(!$adb->close()){
printf STDERR ("close error\n");
}
# tying usage
my %hash;
if(!tie(%hash, "TokyoCabinet::ADB", "casket.tch")){
printf STDERR ("tie error\n");
}
$hash{"quux"} = "touchdown";
printf("%s\n", $hash{"quux"});
while(my ($key, $value) = each(%hash)){
printf("%s:%s\n", $key, $value);
}
untie(%hash);
|