in reply to Re^4: Globbing for file in an unkown directory path only works first time in foreach loop?
in thread Globbing for file in an unkown directory path only works first time in foreach loop?

How many files do you expect to find with

glob('/home/myfiles/day_of_year/'.$day_of_year.'/*/desired_file.txt');

Is it only 1 ?

poj
  • Comment on Re^5: Globbing for file in an unkown directory path only works first time in foreach loop?
  • Download Code

Replies are listed 'Best First'.
Re^6: Globbing for file in an unkown directory path only works first time in foreach loop?
by MarsRover (Novice) on Jan 29, 2016 at 20:52 UTC

    yes only one

    the directory structure looks something like

    /home/myfiles/day_of_year/255/data/JPF_374362/desired_file.txt

    /home/myfiles/day_of_year/256/data/EJF_264827/desired_file.txt

    /home/myfiles/day_of_year/257/data/FFE_387392/desired_file.txt

    where after the data directory there is a day specific ID (three letters, underscore, and then a bunch of numbers, all are unpredictable for each day) and within there is the file named desired_file.txt

      In that case try adding (). I think your problem is that glob in a scalar context, makes it act as an iterator:

      my ($info_desired_filepath) = glob('/home/myfiles/day_of +_year/'.$day_of_year.'/*/desired_file.txt');
      poj