#!/usr/bin/perl
use strict;
$SIG{PIPE} = 'IGNORE';
open (PIPE,"| yourFile.txt") or die "Can't open pipe: $!";
select PIPE;
$|=1;
select STDOUT;
my $count=0;
for (1..10) {
warn "$_\n";
if (print PIPE "number $_\n") {
$count++;
} else {
warn "An error occurred during writing: $!\n";
last;
}
sleep 1;
}
close PIPE or die "Can't close pipe: $!";
print "Wrote $count lines of text\n";
|