/[Search-TokyoDystopia]/scripts/tcqdb.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/tcqdb.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26