小编Hel*_*rld的帖子

寻求功能不在perl中工作

我尝试了下面的代码片段,搜索功能似乎不起作用.

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;
}
Run Code Online (Sandbox Code Playgroud)

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

输出: …

perl file-handling

3
推荐指数
1
解决办法
305
查看次数

标签 统计

file-handling ×1

perl ×1