Created
October 12, 2012 05:31
-
-
Save anonymous/3877489 to your computer and use it in GitHub Desktop.
writedb.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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