in reply to Run code every 6seconde

watch -n 6 unix_command > output_file

No Perl necessary. See watch.