[問題]請問有關dbm的二個例子

看板Perl作者 (^^)時間18年前 (2006/08/28 13:44), 編輯推噓2(201)
留言3則, 2人參與, 最新討論串1/1
各位版友好, 我的系統是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)

08/29 22:37, , 1F
第一個 因為找不到 DB_File 的 module, check 一下吧
08/29 22:37, 1F

08/29 22:38, , 2F
第二個 因為 perl 看不懂此時的 R_DUP O_RDWR 是什麼東西
08/29 22:38, 2F

09/08 11:37, , 3F
感謝樓上的回應
09/08 11:37, 3F
文章代碼(AID): #14yeB2Ki (Perl)