in reply to Re^2: sleep in infinite loop
in thread sleep in infinite loop

Based on the code that you provided, you're not doing anything with any files. Your print statement is only printing to STDOUT (i.e. your monitor).

Assuming that you want to print to both your screen and the file, the modifications to your code below should work.

#!/usr/bin/perl use warnings; use strict; my $file = "file.txt"; open(OF,">",$file) || die "Unable to open file '$file': $!\n"; while (1) { sleep 5; print "interval\n"; # prints to screen print OF "interval\n"; # prints to file } close(OF);