/[Search-TokyoDystopia]/scripts/tcidb.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /scripts/tcidb.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (hide annotations)
Sun Sep 21 14:24:22 2008 UTC (15 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 1016 byte(s)
cleanup paths to casket files
1 dpavlin 30 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use blib;
7     use Search::TokyoDystopia;
8    
9     =head1 NAME
10    
11     tcidb.pl - example from documentation translated to perl
12    
13     =cut
14    
15     # create the object
16     my $idb = tcidbnew();
17    
18     # open the database
19 dpavlin 36 if (!tcidbopen($idb, "casket-idb", IDBOWRITER | IDBOCREAT)) {
20 dpavlin 30 my $ecode = tcidbecode($idb);
21     die "open error: ", tcidberrmsg($ecode);
22     }
23    
24     # store records
25     if(
26     !tcidbput($idb, 1, "George Washington") ||
27     !tcidbput($idb, 2, "John Adams") ||
28     !tcidbput($idb, 3, "Thomas Jefferson")
29     ){
30     my $ecode = tcidbecode($idb);
31     die("put error: ", tcidberrmsg($ecode));
32     }
33    
34     # search records
35     my $result = tcidbsearch2($idb, "john || thomas");
36     if($result){
37     foreach my $i ( @$result ) {
38     my $text = tcidbget($idb, $i);
39     printf("%d\t%s\n", $i, $text);
40     }
41     } else {
42     my $ecode = tcidbecode($idb);
43     die("search error: ", tcidberrmsg($ecode));
44     }
45    
46     # close the database
47     if(!tcidbclose($idb)){
48     my $ecode = tcidbecode($idb);
49     die("close error: ", tcidberrmsg($ecode));
50     }
51    
52     # delete the object
53     tcidbdel($idb);
54    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26