sub identify_changed_dirs { my @dirs = ""; my $touchfile = $gcfounds2mysqlconfig{''}{'touchfile'}; my $gcdir = $geologconfig{''}{'directory'}; # append the sub directory "found" to the working directory $gcdir .= "/found/"; # determine the timestamp of the previous script run my $timestamp = ( stat("$touchfile") )[9]; # change the directory to $gcdir chdir($gcdir) or die "Error: Cannot change to working directory!\n $!"; print "DEBUG 1: changed to the working directory\n$gcdir\n"; # open directory and read all sub directories opendir( DIR, '.' ) or die "Error: Working directory cannot be opened!\n $!"; my $i = 0; #index variable while ( my $subdir = readdir(DIR) ) { # we skip the two special directories ./ and ../ if ( $subdir eq "." ) { next; } if ( $subdir eq ".." ) { next; } # seems unneccessary to calculate the full path! # my $fullpath = $gcdir . $subdir . "\/"; # test whether the current object is a directory if ( -d $subdir ) { # calculate the mtime of the $subdir my $subdir_mtime = ( stat("$subdir") )[9]; if ( $subdir_mtime > $timestamp ) { $i++; #index will be raised when we find a changed directory # TODO TODO: delete this print print "Untersuchung fand $i. geƤndertes Verzeichnis!\n"; # Now we push this sub directory in the array! # Splices replaces the push here! splice( @dirs, @dirs, 0, $subdir ); print @dirs[-1] . "\n"; } } print ".\n"; # TEST Early exit for testing # if ($i == '10'){last;}; } # closes the workdir at end of the main loop closedir(DIR); return (\@dirs); # --> DEBUG: close early # exit; }