chdir $srcdir or die "Can't chdir to '$srcdir': $!\n"; open my $indir, '.' or die "Can't read '.' in $srcdir: $!\n"; (my $tarfile = $srcdir) =~ s|.*/||; $tarfile = "$destdir/$tarfile-" . time . '.tar'; my @files = grep { -f and -M <= 1 } readdir $indir; # packing all files at once doesn't work with large directories # (limit of command line length) while(my $file = shift @files) { system ('tar', 'uf', $tarfile, $file) and die "Can't pack '$file' into '$tarfile' (exitcode $?)\n"; } system ('gzip', $tarfile) and die "Couldn't gzip $tarfile (exitcode $?)\n";