Thanks for your help. I did try the modification you suggested. Now the
program does not die (it does not have that option), however when I ask it
to list the contents of the file, it does not do anything either. Here is
my code again:
#!/usr/bin/perl
use CGI ':standard';
use DB_File;
$filename = "./mockalias";
tie %ALIAS, "DB_File", "$filename", O_RDWR|O_CREAT, 0644, $DB_HASH;
$key = "vrunda";
if (exists $ALIAS{$key})
{
print "$key has value $ALIAS{$key}\n";
}
print "$ALIAS";
untie %ALIAS;
-----Original Message-----
From: [EMAIL PROTECTED]
To: Prabhu, Vrunda P (UMC-Student)
Cc: '[EMAIL PROTECTED]'
Sent: 6/18/01 1:29 PM
Subject: Re: PERL DB Question
Try this instead
tie %ALIAS, "DB_File", "$filename", O_RDWR|O_CREAT, 0644, $DB_HASH;
"Prabhu, Vrunda P (UMC-Student)" wrote:
> I have an existing file, called mockalias that contains entries in the
> following format:
>
> username : e-mail address
> I want to use a hash %ALIAS to read the mockalias file into the hash,
and
> then be able to delete,
> update, add entries to this hash. When I run the following code, it
tells
> me that the file
> mockalias exists, and dies. How can I read the file into a hash and
> manipulate the entries
> of the hash?
>
>
> #!/usr/bin/perl
> use CGI ':standard';
> use DB_File;
> $filename = "mockalias";
> tie (%ALIAS, "DB_File", $filename) or
> die "cannot open file $filename:$!\n";
> untie %ALIAS;
>
> Thanks in advance for your time.
> Vrunda