perl - -d : not matching my folder -
I have a problem with this code. Matching and .. , but not others Can you explain to me?
My $ checked_directory = $ Test_directory '\ Sources'; Opendir (Checked_directory, $ Checked_directory) or Printed STDOUT "\ n 101- $ Checked_directory Open $ $! \ N"; @ Fils = reddir (checked_directory); # The file list is checked in the foreach foreach in my $ fileToTest (@files) {print $ fileToTest. "\ N"; #debug if ($ fileToTest = ~ m / .jpg $ /) {print 'file ...' $ $ FileToTest "\ N"; $ Localization_file = $ Test_directory '\ Source \\' $ FileToTest; #file to test} alsf (-d $ fileToTest) {print ">"> gt;> gt; & gt; " . $ FileToTest "\ N"; }} Closed (checked directory); Name in
@files , as you feel aware , There is no path information, which means that -d looks for them in the current working directory, fails to find them, and reports false, this is a -e < / Code> (present) test.
You should change your code in this way. Note that the identity cards that begin with capital letters are reserved for the global identifier. It is also a bad idea to use bordered files and directory handles - lexical handles are the best practice.
my $ checked_directory = "$ test_directory \\ source"; Opendir $ checked_dh, $ checked_directory or print STDOUT "\ n 101- $ check = open directory: $! \ N"; While (my $ file_to_test = readdir $ check_dh) {print "$ file_to_test \ n"; My $ localisation_file = "$ test_directory \\ source \\ $ file_to_test"; If (-d $ localisation_file) {print ">"> gt;>> $ file_to_test \ n "; } Elsf ($ file_to_test = ~ / jpg $ /) {print "file ... $ file_to_test \ n"; }} Closed $ check_diff;
Comments
Post a Comment