# STEP 2.6 --> get_foundtime_from_garmin sub get_foundtime_from_garmin { my $cache_id = shift; my $foundtime_from_garmin = ''; if ( -f $garminfoundfile ) { print " DEBUG get_foundtime_from_garmin 1: GARMIN CONNECTED: $garminfoundfile\n"; # sleep for 1 second because we open and close the file again and again sleep 1; # read exact timestamp from files open GCVISITSFILE, "){ # read the current line my $line = $_; # removing the last two characters chop($line); chop($line); # split $line into comma separated strings my @currentline = split(/,/,$line); # check whether the $cache_id is listed in the beginning of the $currentline if ($currentline[0] eq "$cache_id") { # found the $cache_id print " Found GCid $currentline[0] in geocache_visits.txt file\n". " Reading time of found...\n"; $foundtime_from_garmin = $currentline[1]; } } close(GCVISITSFILE); # close file again } else { # setting return code to "n/a" when the geocache_visits.txt # file is not accessible $foundtime_from_garmin = "n/a"; } return $foundtime_from_garmin; }