Ramprasad A Padmanabhan wrote:
Hi,
I have a simple script that reads a hashDB file into a tied hash.
When I do a Dumper , I get the hash values , but when I pring a value
nothing is printed ... what am I doing wrong here ?
--------------------------------------------
use DB_File;
use strict;
use Data::Dumper;
my %hash;
my $DATAFILE = "sample.db";
tie %hash, 'DB_File', $DATAFILE, O_RDONLY , 0666 , $DB_HASH;
print Dumper([\%hash]);
print "VALUE for a is '" . $hash{a}."' \n";
---------------------------------------------------------
OUTPUT
-------------------------------------------------------
$VAR1 = [
{
'b' => '2',
'a' => '1',
'c' => '3'
}
];
VALUE for a is ''
---------------------------------------------------------
Thanks
Ram
Ok I got it , I must install the DBM filters for it
I put
$X->filter_fetch_key ( sub { s/\0$// } ) ;
$X->filter_store_key ( sub { $_ .= "\0" } ) ;
$X->filter_fetch_value( sub { s/\0$// } ) ;
$X->filter_store_value( sub { $_ .= "\0" } ) ;
Now things are working fine
Bye
Ram
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>