ITPub博客

首页 > Linux操作系统 > Linux操作系统 > perl判断某个打开的文件是否匹配某模式

perl判断某个打开的文件是否匹配某模式

原创 Linux操作系统 作者:chyf1983 时间:2010-06-10 14:51:11 0 删除 编辑
sub is_pattern_data_zip_file
{
    my ($gzh, $pattern) = @_;
    my $temp;
    #read the entire file
    {
        local $/;
        $temp = <$gzh>;
    }
    return 1 if ($temp =~ /$pattern/) or return 0;
}
sub is_pattern_data_zip_file2
{
    my ($gzh, $pattern1, $pattern2) = @_;
    my $temp;
    #read the entire file
    {
        local $/;
        $temp = <$gzh>;
    }
    $_ = $temp;
    return 1 if (/$pattern1/ || /$pattern2/) or return 0;
}
sub is_pattern_data_zip_file3
{
    my $gzh = shift;
    my $temp;
    #read the entire file
    {
        local $/;
        $temp = <$gzh>;
    }
    foreach(@_) {
        if ($temp =~ /$_/) {
            return 1;
        }
    }
    return 0;
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/677997/viewspace-664899/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: perl读写excel文档
请登录后发表评论 登录
全部评论

注册时间:2010-06-09

  • 博文量
    8
  • 访问量
    9808