Skip to content

Instantly share code, notes, and snippets.

Created October 12, 2012 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3877489 to your computer and use it in GitHub Desktop.
Save anonymous/3877489 to your computer and use it in GitHub Desktop.
writedb.pl
#!/usr/bin/env perl
use strict;
use warnings;
use DB_File;
use Fcntl;
sub get_data {
my $data;
# open my $fh, "</dev/urandom" or die "Can't open /dev/urandom for reading: $!";
# sysread $fh, $data, 20;
# close $fh;
$data = 'A' x 20;
$data;
}
my @arr;
my $recno = DB_File::RECNOINFO->new();
$recno->{flags} |= R_FIXEDLEN;
$recno->{reclen} = 100;
for(my $i = 0; $i < 2; $i++) {
my $h = tie(@arr, 'DB_File', "test.db", O_CREAT|O_RDWR, 0600, $recno) or die "Can't tie file: $!";
my $str = get_data();
$h->push($str);
$h->sync();
undef $h;
untie @arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment