#!/usr/bin/perl use Proc::Daemon; Proc::Daemon::Init; use File::Copy; @dirs=qw(/mail/act1/ /mail/act2/ /mail/act3/ /mail/act4/); while(1){ $dir="/mail/main/"; opendir(MAIN,$dir) or die "Can't open $dir:$!"; while(defined($file = readdir MAIN)){ next if $file =~/^\.\.?$/; $path=$dir.$file; $newdir=@dirs[$i]; move ($path,"$newdir$file") or die "move failed:$!"; $i++; undef $i if ($i>$#dirs); } }