Anders Stegmann am Montag, 6. Februar 2006 12.30:
> Hi!

Hi Anders

> Can anyone tell me why this script doesn't work?
>
>
> use strict;
> use warnings;
>
> my %hash = ();
>
> my $key1 = 'nul';
> my $en = 'en';
> my $to = 'to';
> my $tre = 'tre';
>
>
> $hash{$key1} = [$en, $to, $tre];
>
> dbmopen(my %dbm_result_hash, 'hash_database', 0666) or die cannot save
> database_name to dbm\n;

No quotes around the string after die. This is a syntax error.

> %dbm_result_hash = %hash;
>
> dbmclose(%dbm_result_hash);
>
> dbmopen(my %dbm_hash, 'hash_database', 0666);
>
> my ($key) = keys %dbm_hash;

Not shure if this is intended. $key contains the first key of the list of  
keys from %dbm_hash, which itself has not a specific order.

> print $dbm_hash{$key}[2],\n;
>
> dbmclose(%dbm_hash);
>
> exit;

No need for an exit at the end of a script.

btw, from 

perldoc -f dbmopen:

dbmopen HASH,DBNAME,MASK
               [This function has been largely superseded by the "tie" 
function.]


hth, 
joe

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to