Perl 文件操作 (IO::File)
2015-06-15 10:59
459 查看
# author : ez # date 2015/6/15 # describe : append write a file #! perl use strict; use warnings; use IO::File; # import symbols my $fname = "./ko.pl"; my $fd = undef; sub main () { $fd = new IO::File $fname, O_WRONLY | O_APPEND; # write only and append print $fd "this sentends;\n"; # write string into <$fd> $fd -> setpos ($fd -> getpos); undef $fd; # automatically close file handle } &main;
基本的读取:
sub rf () {
# or this
# my $fname = "> ./ko.pl"; then you can read without calling open ()
my $fname = "./ko.pl";
$fd = new IO::File; # call constructor
$fd -> open ($fname);
print <$fd>; # print all content of this file
$fd -> close;
}
&rf;
相关文章推荐
- Perl模块编写说明
- perl如何避免脚本在windows中闪一下就关闭
- Perl中的特殊内置变量详细介绍
- linux下使用perl获取本机ip的几种方法介绍
- perl 控制结构 条件控制 if while
- Perl中的列表和数组学习笔记
- perl数据库添加、删除、更新、查询操作例子
- perl操作MongoDB报错undefined symbol: HeUTF8解决方法
- Perl中使用MIME::Lite发送邮件实例
- 什么是Perl?编程语言Perl详细介绍
- About Perl(翻译Perl官网介绍)
- perl 基本语法介绍
- perl 模式匹配参数详解
- PERL脚本 学习笔记
- perl 列表和数组变量详解
- 探索Perl的世界(更新到40集)-Perl视频教程
- perl 文件读写详细说明
- perl中5个常见错误
- Perl ASCII 字符判断
- perl 学习资料整理篇第1/4页