my %h; my $data_db = "data_db"; tie (%h, 'DB_File', "$data_db") or die $!; if (not exists($h{$id})) { $h{$id} = 'some value'; } untie %h;