-->
利用Tie::File可以将文件的内容看着是一个数组来操作,具体示例如下:
[supersun@supersun.biz perl]$ cat tie.pl
#!/usr/bin/perl -w
use strict;
use Tie::File;
my $file=shift;
my @arrary;
tie @arrary,'Tie::File',$file;
push @arrary,"hello";
在文件的结尾增加一行:hello
[supersun@supersun.biz perl]$ cat test
aaaaa
[supersun@supersun.biz perl]$ perl tie.pl test
[supersun@supersun.biz perl]$ cat test
aaaaa
hello
[supersun@supersun.biz perl]$
我使用这个模块的目的主要是用于处理inotify脚本生成的日志文件,因为之前一直使用logrotate及cron来实现文件的上传,cron的最小时间间隔是1分钟,间隔稍长了一点。

发表评论