Despite your updates, you still haven't shown us the code you are really running so I'm still not entirely sure what you are trying to accomplish but this should give you a push in the right direction.

#!/bin/env perl use strict; use warnings; my @day_of_year = (4257,4257,4258,4259); # If @day_of_year only contains the days then there is no reason for m +atching for my $day_of_year (@day_of_year) { print "looking for things in $day_of_year folder /home/myfiles/day_o +f_year/$day_of_year/*/desired_file.txt\n"; # there may be multiple directories containing desired_file.txt my @desired_paths = glob('/home/myfiles/day_of_year/'.$day_of_year.' +/*/desired_file.txt'); for my $info_desired_filepath (@desired_paths) { print "$info_desired_filepath \t\t is the file name \n\n"; <STDIN>; open (my $info_FH, '<', $info_desired_filepath) or die "cannot open $info_desired_filepath..........\n\n"; print "found a file!!!!!!\n"; chomp(my @lines = <$info_FH>); close($info_FH); print "lines:\n"; print "$_\n" for @lines; # yep, we actually read the data } } __DATA__ Directory structure: myfiles/ day_of_year/ |-- 4257 | |-- a | | `-- desired_file.txt | |-- b | | `-- desired_file.txt | `-- c | `-- desired_file.txt |-- 4258 | |-- a | | `-- desired_file.txt | `-- c | `-- desired_file.txt `-- 4259 `-- c `-- desired_file.txt Output: skimming for the day of year number: 4257 looking for things in 4257 folder /home/myfiles/day_of_year/4257/*/des +ired_file.txt /home/myfiles/day_of_year/4257/a/desired_file.txt is th +e file name found a file!!!!!! lines: data /home/myfiles/day_of_year/4257/b/desired_file.txt is th +e file name found a file!!!!!! lines: data /home/myfiles/day_of_year/4257/c/desired_file.txt is th +e file name found a file!!!!!! lines: data bogus data skimming for the day of year number: 4257 looking for things in 4257 folder /home/myfiles/day_of_year/4257/*/des +ired_file.txt /home/myfiles/day_of_year/4257/a/desired_file.txt is th +e file name found a file!!!!!! lines: data /home/myfiles/day_of_year/4257/b/desired_file.txt is th +e file name found a file!!!!!! lines: data /home/myfiles/day_of_year/4257/c/desired_file.txt is th +e file name found a file!!!!!! lines: data bogus data skimming for the day of year number: 4258 looking for things in 4258 folder /home/myfiles/day_of_year/4258/*/des +ired_file.txt /home/myfiles/day_of_year/4258/a/desired_file.txt is th +e file name found a file!!!!!! lines: data /home/myfiles/day_of_year/4258/c/desired_file.txt is th +e file name found a file!!!!!! lines: data bogus data skimming for the day of year number: 4259 looking for things in 4259 folder /home/myfiles/day_of_year/4259/*/des +ired_file.txt /home/myfiles/day_of_year/4259/c/desired_file.txt is th +e file name found a file!!!!!! lines: data

Updated: Added directory structure and output from my test run.


In reply to Re: Globbing for file in an unkown directory path only works first time in foreach loop? by Mr. Muskrat
in thread Globbing for file in an unkown directory path only works first time in foreach loop? by MarsRover

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.