chenhao392的个人博客分享 http://blog.sciencenet.cn/u/chenhao392

博文

学习笔记:两个perl模块

已有 3719 次阅读 2012-6-22 08:06 |个人分类:学习|系统分类:科研笔记| 学习, 模块

1. DB_File
这个model可以将一个hash table 存储到硬盘上。

write.pl
#!/usr/bin/perl
use strict;
use warnings;
use DB_File;

my %hash;
tie(%hash,"DB_File","test.db") or die "$!\n";
$hash{"key"}="Hello World!";

read.pl
#!/usr/bin/perl
use strict;
use warnings;
use DB_File;

my %hash;
tie(%hash,"DB_File","test.db") or die "$!\n";
print "$hash{'key'}\n";

Run
perl write.pl
perl read.pl
> Hello World!

2. Smart::Comments
打印注释的功能在调试程序时十分有用,在扶凯的blog中发现 :) 注释掉use Smart::Comments;后,所有的 ### 注释变身普通注释。

#!/usr/bin/perl

use Smart::Comments;

for(1..3){### For loop
        print "num: $_n";
        print "testn";
}




https://blog.sciencenet.cn/blog-395566-584622.html

上一篇:学习笔记:几个有用的perl的模块
收藏 IP: 150.135.37.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-18 13:07

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部