use warnings; use CouchDB::Client; my $c = CouchDB::Client->new(uri => 'http://127.0.0.1:5984/'); my $db = $c->newDB('test'); my ($doc) if ($db->docExists('12345')) { print "hello\n"; } else { $doc = $db->newDoc('12345', undef, {'foo'=>'bar'})->create; } print $doc->retrieve('12345');