作者roger (^^)
看板perl
标题[问题]请问有关dbm的二个例子
时间Mon Aug 28 13:50:29 2006
各位版友好,
我的系统是xp,安装ActivePerl-5.8.8.817-MSWin32-x86-257965.msi。
我试了二个dbm的小例子,(已安装DB_File)
但都有错误讯息发生,
请教一下是否忽略了什麽细节。
谢谢。
1.
程式码如下:
#! c:\Perl\
use strict;
use DB_File;
use Fcntl;
$filename = "test";
tie %hash, "DB_File", $filename;
$hash{'John'} = '27365124';
$hash{'Mary'} = '26421382';
system (pause);
错误讯息如下:
C:\perl_examples>perl perle.pl
Can't locate DB_File.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .)
at perle.pl line 3.
BEGIN failed--compilation aborted at perle.pl line 3.
2.
程式码如下:
#! c:\Perl\
use strict;
my $DB_BTREE -> {'flags'} = R_DUP;
my $tie = tie my %h, "DB_FILE", "test", O_RDWR, 0644, $DB_BTREE or die $!;
system (pause);
错误讯息如下:
C:\perl_examples>perl perle.pl
Bareword "R_DUP" not allowed while "strict subs" in use at perle.pl line 5.
Bareword "O_RDWR" not allowed while "strict subs" in use at perle.pl line 6.
Execution of perle.pl aborted due to compilation errors.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.247.68
※ 编辑: roger 来自: 140.116.247.68 (08/28 15:35)
1F:推 reizarc:第一个 因为找不到 DB_File 的 module, check 一下吧 08/29 22:37
2F:→ reizarc:第二个 因为 perl 看不懂此时的 R_DUP O_RDWR 是什麽东西 08/29 22:38
3F:推 roger:感谢楼上的回应 09/08 11:37