foreach my $file (@files) { # Only look for the 'upload complete' marker files next unless $file =~ /^(.*)\.complete$/; # extract the name of the 'real' file my $base_name = $1; # insert into db pqinsert( $file_dir . $base_name ); # move real file into archive dir move( $file_dir . $base_name, $archive_dir . $base_name ) || die "can't move: to $archive_dir - $!"; # remove the 'complete' marker file unlink($file) || die "can't unlink $file - $!" }