in reply to crontab question

As Wookie says, cron does not set up an environment unless you tell it to. That can be done at the head of the crontab file.

Obligatory pickiness: use strict;. That would show that all your variables are global. That is not causing problems in your script since all the names are different. Later modifications could give puzzling failures if a generic temp like $i or $time were reused.

After Compline,
Zaxo