in reply to sequential file handling (yet again)
If your program is the only one writing to these dirs, you can sort them by mtime, as you can for files that appear in /main:
If mtime of the inodes is not helpful, you'll need to keep some sort of persistent data file. I also would like to know why each of the other solutions failed.my @dirs = ('/dir1/', '/dir2/', '/dir3/', '/dir4/', '/dir5/', '/dir6/' +,); my @newfiles = sort {-M $b <=> -M $a} grep {-f } glob("/main/*"); my @seq = (sort {-M $b <=> -M $a} @dirs) x int( 1 + @newfiles/@dirs); for (@newfiles) { my $status = system '/bin/cp', '-f', $_, shift @seq; die 'Copy failed for ', $_, ': Child Error ', $?, $! if $status; unlink $_ unless $status; }
After Compline,
Zaxo
|
|---|