⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdbfile.pl

📁 perl learn perl by examples
💻 PL
字号:

#-----------------------------------------------------------------
# Testing DB_File
#
use DB_File;
use  Fcntl;
$file = 'test';
tie (%h, 'DB_File', $file, O_RDWR|O_CREAT, 0666, $DB_BTREE);
$DB_BTREE->{'compare'} = \&sort_ignorecase;
sub sort_ignorecase {
    my ($key1, $key2) = @_;
    $key1 =~ s/\s*//g;          # Get rid of white space
    $key2 =~ s/\s*//g;    
    lc($key1) cmp lc($key2);    # Ignore case when comparing
}

$h{abc} = "ABC";
$h{def} = "DEF";
$h{ghi} = "GHI";
untie (%h);

tie (%g, 'DB_File', $file, O_RDWR|O_CREAT, 0640, $DB_BTREE);

print "Retrieving individual elements...\n\t";
print $g{abc}," ", $g{def}, " ", $g{ghi}, "\n";

print "Retrieving keys...\n\t";
$, = " ";
print keys(%g);
untie(%g);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -