in reply to Re: 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?
Okay, actual code:
#!/tps/bin/perl -s my @day_of_year = (4257,4257,4258,4259); foreach (@day_of_year) { print"\nskimming for the day of year number:\n"; if ($_ =~ /(\d{4})/){ $day_of_year = $1; print "looking for things in $day folder /home/myfiles +/day_of_year/$day_of_year/*/desired_file.txt\n"; my $info_desired_filepath = glob('/home/myfiles/day_of +_year/'.$day_of_year.'/*/desired_file.txt'); print "$info_desired_filepath \t\t is the file name \n +\n"; <STDIN>; open ($info_FH, '<', $info_desired_filepath) or die "cannot open $info_desired_filepath.... +......\n\n"; print "found a file!!!!!!\n"; chomp(@lines = <$info_FH>); close($info_FH); } }
actual output:
skimming for the day of year number:
looking for things in 4257 folder /home/myfiles/day_of_year/4257/*/desired_file.txt
/home/myfiles/day_of_year/4257/JKY_63521/desired_file.txt is the file name
found a file!!!!!!
skimming for the day of year number:
looking for things in 4257 folder /home/myfiles/day_of_year/4257/*/desired_file.txt is the file name
cannot open ..........end output
|
|---|