E
Eric
We have an existing database named 'DBfile' that was created using
MLDBM. I want to modify the value of 'Cnt' in this database using the
following script:
=============================================
#! /usr/bin/perl
use Data:umper;
use Fcntl;
use MLDBM qw(DB_File Storable);
&DBprint("nfs", "32039", '0');
sub DBprint {
my $protocol = shift;
my $bldNum = shift;
my $mntPnt = shift;
my $DBFile = "./DBfile";
tie( %$mntsDB, "MLDBM", $DBFile, O_CREAT|O_RDWR, 0666,
$DB_File:B_BTREE );
$mntPnt = "mnt".$mntPnt;
print STDOUT "\nBEFORE\n";
print STDOUT (Dumper $mntsDB);
print STDOUT "\nInitial Cnt is: $mntsDB->{$mntPnt}->{Cnt};\n";
my $tmp = $mntsDB->{$mntPnt}->{Cnt};
print STDOUT "\n\$tmp is: $tmp\n";
$tmp{Cnt}[0] = 'foo'; ## key line of code
print STDOUT "\n\$tmp is now: $tmp->{Cnt}[0]\n";
$mntsDB->{$mntPnt}->{Cnt} = $tmp;
print STDOUT "\nCnt is now: $mntsDB->{$mntPnt}->{Cnt};\n";
print STDOUT "\nAFTER\n";
print STDOUT (Dumper $mntsDB);
untie(%$mntsDB);
}
=============================================
But note in the output below that the value is not modified:
=============================================
BEFORE
$VAR1 = {
'mnt0' => {
'Cnt' => 2,
'BldNum' => '32039',
'Protocol' => 'nfs'
}
};
Initial Cnt is: 2;
$tmp is: 2
$tmp is now: foo
Cnt is now: 2;
AFTER
$VAR1 = {
'mnt0' => {
'Cnt' => 2,
'BldNum' => '32039',
'Protocol' => 'nfs'
}
};
=============================================
I read the CPAN page carefully, and although it seems as if this
should work, it does not. The Cnt value is not getting reset to the
value 'foo'.
Does anyone see where I am making my mistake? I noted a key line of
code in the script that I think may be preventing this from working,
although I did try several variations. I'm thinking that maybe I am
getting tangled up in my references.
Thanks.
Eric
MLDBM. I want to modify the value of 'Cnt' in this database using the
following script:
=============================================
#! /usr/bin/perl
use Data:umper;
use Fcntl;
use MLDBM qw(DB_File Storable);
&DBprint("nfs", "32039", '0');
sub DBprint {
my $protocol = shift;
my $bldNum = shift;
my $mntPnt = shift;
my $DBFile = "./DBfile";
tie( %$mntsDB, "MLDBM", $DBFile, O_CREAT|O_RDWR, 0666,
$DB_File:B_BTREE );
$mntPnt = "mnt".$mntPnt;
print STDOUT "\nBEFORE\n";
print STDOUT (Dumper $mntsDB);
print STDOUT "\nInitial Cnt is: $mntsDB->{$mntPnt}->{Cnt};\n";
my $tmp = $mntsDB->{$mntPnt}->{Cnt};
print STDOUT "\n\$tmp is: $tmp\n";
$tmp{Cnt}[0] = 'foo'; ## key line of code
print STDOUT "\n\$tmp is now: $tmp->{Cnt}[0]\n";
$mntsDB->{$mntPnt}->{Cnt} = $tmp;
print STDOUT "\nCnt is now: $mntsDB->{$mntPnt}->{Cnt};\n";
print STDOUT "\nAFTER\n";
print STDOUT (Dumper $mntsDB);
untie(%$mntsDB);
}
=============================================
But note in the output below that the value is not modified:
=============================================
BEFORE
$VAR1 = {
'mnt0' => {
'Cnt' => 2,
'BldNum' => '32039',
'Protocol' => 'nfs'
}
};
Initial Cnt is: 2;
$tmp is: 2
$tmp is now: foo
Cnt is now: 2;
AFTER
$VAR1 = {
'mnt0' => {
'Cnt' => 2,
'BldNum' => '32039',
'Protocol' => 'nfs'
}
};
=============================================
I read the CPAN page carefully, and although it seems as if this
should work, it does not. The Cnt value is not getting reset to the
value 'foo'.
Does anyone see where I am making my mistake? I noted a key line of
code in the script that I think may be preventing this from working,
although I did try several variations. I'm thinking that maybe I am
getting tangled up in my references.
Thanks.
Eric