perl读取文件
来源:互联网 发布:最优化方法第二版 编辑:程序博客网 时间:2024/06/05 19:50
1)文件读取的3中方法
按行读,存入标量
while (<FILE>) { print; }
按行读,存入数组
@array = <FILE>;
读入整个文件 ,存入标量
$string = do { local $/; <FILE>; };
2)读文件实例
open (EP,"/etc/passwd");
while (<EP>) {
chomp;
print "I saw $_ in the password file!\n";
}
while (<EP>) {
chomp;
print "I saw $_ in the password file!\n";
}
3)读写文件实例
open(IN,$a) || die "cannot open $a for reading: $!";
open(OUT,">$b") || die "cannot create $b: $!";
while (<IN>) { # read a line from file $a into $_
print OUT $_; # print that line to file $b
}
close(IN) || die "can't close $a: $!";
close(OUT) || die "can't close $b: $!";
open(OUT,">$b") || die "cannot create $b: $!";
while (<IN>) { # read a line from file $a into $_
print OUT $_; # print that line to file $b
}
close(IN) || die "can't close $a: $!";
close(OUT) || die "can't close $b: $!";
来自:http://yixf.name/2011/04/26/perl%E8%AF%BB%E5%8F%96%E6%96%87%E4%BB%B6%E4%B8%89%E6%B3%95/
- perl读取excel文件
- Perl打开读取文件
- perl 文件读取
- perl读取文件
- Perl打开读取文件
- perl 读取文件
- perl读取文件内容
- perl文件读取之心得
- perl文件读取之心得
- 关于perl的文件读取
- perl几个读取文件命令
- Perl读取wtmpx日志文件
- 使用Perl读取Excel文件
- Perl 读取文件并进行split
- Perl Audio::WMA读取WMA文件信息
- [NPWP笔记]使用perl读取文件
- 读取excel文件(使用perl处理)
- perl正则表达式,文件读取常用方法
- html的header结构和实例
- perl-cgi高级
- perl去除字符串前后的空格
- grep 小技巧
- [SCM]源码管理 -perforce label实例
- perl读取文件
- perl-cgi-form2
- 15条SQLite3语句
- cocos2d-x学习资源汇总
- SQL快速查找
- perl命令+关键字
- LinuxTips-cp命令
- 安装你自己的perl modules
- Mitchell机器学习-遗传算法