in reply to problem with redirection and piping

I tried your script using File::Tee by salva. It responded pretty much as BrowserUk said tee would. Here's the code, minus the print statements:
#!/usr/bin/perl use strict; use warnings; use File::Tee qw(tee); tee('STDOUT', '>>', 'stdout.txt'); $| = 1; my $i = 0; $SIG{'INT'} = 'handler_of_int'; sub handler_of_int { close('STDOUT'); exit(0); } while (1) { print STDOUT ++$i, "\n"; sleep (1); }