This is wackyass, a webcam archiving system. No, it's not commented, and no there's no POD. This was a little project I did at home to archive single frame pics on a 24 hour rotation. use FileHandle; use LWP::Simple; if ($ARGV[0] eq 'stop') { $kill = 1; } if (-e 'pidfile') { $running = 1; } if ($kill and $running) { $pfh = new FileHandle 'pidfile', O_RDONLY; chomp($pid = $pfh->getline); chomp($stime = $pfh->getline); undef $pfh; $skill = kill 9, $pid; $srm = unlink 'pidfile'; if ($skill and $srm) { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); $etime = '0' x (2 - length($hour)).$hour.':'.'0' x (2 - length($min)).$min.':'.'0' x (2 - length($sec)).$sec.' '.'0' x (2 - length($mon + 1)).($mon + 1).'/'.'0' x (2 - length($mday)).$mday.'/'.($year + 1900); $lfh = new FileHandle '../log/logfile', O_CREAT|O_APPEND; print $lfh "wackyass:$pid start time: $stime\n"; print $lfh "wackyass:$pid end time: $etime\n"; undef $lfh; } elsif ($skill) { print "\nUnable to remove the pidfile.\n"; } elsif ($srm) { print "\nUnable to kill $pid.\n"; } exit(0); } elsif ($kill) { print "\nWackyass is not currently running.\n"; exit(0); } elsif ($running) { print "\nWackyass is currently running.\n"; exit(0); } ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); $stime = '0' x (2 - length($hour)).$hour.':'.'0' x (2 - length($min)).$min.':'.'0' x (2 - length($sec)).$sec.' '.'0' x (2 - length($mon + 1)).($mon + 1).'/'.'0' x (2 - length($mday)).$mday.'/'.($year + 1900); $ppid = $$; $pfh = new FileHandle 'pidfile', O_CREAT|O_WRONLY; print $pfh "$$\n$stime\n"; undef $pfh; if ($pid = fork) { $lmin = -1; $i = 0; for (;;) { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); $ssec = $sec; if ($lmin != $min) { $i = 0; $lmin = $min; } if ($sec > 50) { $i = 0; $min++; $lmin = $min; } if ($i > 5) { $i = 0; } if ($min == 60) { $min = 0; $lmin = $min; $hour++; } if ($hour == 24) { $hour = 0; } $filename = '/usr/local/apache/sites/wackyass/htdocs/'.'0' x (2 - length($hour)).$hour.'/'.'0' x (2 - length($min)).$min.$i.'.jpg'; $ifh = new FileHandle "$filename", O_CREAT|O_WRONLY; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); if ($sec < $ssec) { $sec += 60; } $stime = 10 - ($sec - $ssec); sleep $stime; print $ifh get("http://192.168.0.108:8080"); undef $ifh; $i++; } } elsif (defined $pid) { for (;;) { ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); $min++; if ($min == 60) { $hour++; if ($hour == 24) { $hour = 0; } $min = 0; } for ($i = 0; $i < 6; $i++) { $filename = '/usr/local/apache/sites/wackyass/htdocs/'.'0' x (2 - length($hour)).$hour.'/'.'0' x (2 - length($min)).$min.$i.'.jpg'; if ((-M $filename) >= 0.5) { unlink $filename; } } if ($ppid != getppid) { kill 9, $$; } sleep 60; } }