加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

寻求功能不在perl中工作

发布时间:2020-12-16 06:05:47 所属栏目:大数据 来源:网络整理
导读:我尝试了下面的代码片段,搜索功能似乎不起作用. funct("ls -ltr /scratch/dummy/dum*");sub funct {print "nRecordingn";open(SENSOR_LIST1,"$_[0] |") || die "Failed to read sensor list: $!n";for $sensor_line1 (SENSOR_LIST1) { print "$sensor_lin
我尝试了下面的代码片段,搜索功能似乎不起作用.

funct("ls -ltr /scratch/dummy/dum*");

sub funct {

print "nRecordingn";
open(SENSOR_LIST1,"$_[0] |") || die "Failed to read sensor list: $!n";
for $sensor_line1 (<SENSOR_LIST1>) {
   print "$sensor_line1";
}
my $pos = tell SENSOR_LIST1;
print "nposition is $pos"; #Here the position is 613

print "nRecording again";
seek (SENSOR_LIST1,SEEK_SET,0);
$pos = tell SENSOR_LIST1; # Here again the position is 613,even after a seek
print "nposition now is $pos";

for $sensor_line1 (<SENSOR_LIST1>) {
        print "$sensor_line1";
    }
close SENSOR_LIST1;
}

注意:所有搜索变体都不起作用.

输出:

即使在寻求之后,该位置也不会改变.它仍然在613.

你们可以检查并告诉我这里的问题是什么?

谢谢.

解决方法

你不能在管道上寻找.

使用临时文件或将数据存储在内存中.

您选择最佳解决方案

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读