Sending the Output of a Filter to a File: open(STDOUT, ">/dev/tty");
#!/usr/bin/perl
# Program to redirect STDOUT from filter to a UNIX file
$| = 1;
$tmpfile = "temp";
open(DB, "data.txt") || die qq/Can't open "data": $!\n/;
open(SAVED, ">&STDOUT") || die "$!\n";
open(STDOUT, ">$tmpfile" ) || die "Can't open: $!\n";
open(SORT, "| sort +1") || die; while(<DB>){
print SORT;
}
close SORT;
open(STDOUT, ">&SAVED") || die "Can't open";