我尝试了下面的代码片段,搜索功能似乎不起作用.
funct("ls -ltr /scratch/dummy/dum*"); sub funct { print "\nRecording\n"; 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.
你们可以检查并告诉我这里的问题是什么?
谢谢.