#!/usr/bin/perl -w use strict; use warnings; my $fname = "delayer.out"; open(OUT,">",$fname) || die("Cannot open $fname: $!"); select OUT; $| = 1; # make unbuffered select STDOUT; $| = 1; # make unbuffered my $count = 60; while ($count--) { my $str = "$count: The time is now ".localtime()."\n"; print $str; print OUT $str; sleep 1; }