Berkeley DB perl access

From: Ninan Thomas (nin234_at_yahoo.com)
Date: 06/17/04

  • Next message: Andy Squires: "Anyone working on DBD::Unidata?"
    Date: 17 Jun 2004 10:04:29 -0700
    
    

    I am using Perl to retrieve data from a Berkeley DB database, which
    was created and records inserted ,using C++. The key of the database
    is a C++ struct

    typedef struct {
       struct timeval begin_time;
       int client_port;
       char client_ip[IP_ADDR_CHAR_ARRAY_LEN];
    } probeBerkDBkey;

     Can I retrieve the records using BerkeleyDB perl module? How to do
    this ?

    I am enclosing a partial non working Perl script for reference

    #!/usr/local/bin/perl

     

    use strict ;

    use BerkeleyDB ;

     

    my $filename = "SQL_3306" ;

    my %h ;

     

    tie %h, 'BerkeleyDB::Btree',

            -Filename => $filename,

            -Subname => 'CompleteRequests'

      or die "Cannot open $filename: $!\n" ;

     

    # Cycle through the keys printing them in order.

    # Note it is not necessary to sort the keys as

    # the btree will have kept them in order automatically.

     

    foreach (keys %h)

      { print "$_}\n" }

     

    untie %h ;

    Regards

    Ninan


  • Next message: Andy Squires: "Anyone working on DBD::Unidata?"