4 ms·
Here is probably the simplest answer, it's not totally correct but it's the shortest answer that fits the main criteria. #!/usr/bin/perl use strict;
by tankenmate 9y ago
Here is probably the simplest answer, it's not totally correct but it's the shortest answer that fits the main criteria.
#!/usr/bin/perl
use strict;
sub f
{
my $outputFH=shift;
print $outputFH "--\n";
open(my $lsFH,"ls /|") or die("pipe ls: $?");
print $outputFH (<$lsFH>);
close($lsFH);
print $outputFH "--\n";
}
open(my $outTxtFH,">","out.txt") or die("open: out.txt:$?");
f($outTxtFH);
close($outTxtFH);
open(my $wcFH,"|wc -l") or die("pipe wc: $?");
f($wcFH);
close($wcFH);