Use system() for the commands (or IO::Open2 if they need IO) and chdir() to change directories. For sleeping, you could either ignore the time it takes to execute the commands, use the start/stop times to put in a correction (which will gradually increase the longer your script is on), or a time-$time like construction employing the % operator. Or you could use a cron script, which would probably be a better choice.