perl - Escape whitespace when using backticks -


I have a search, and the only way to use backlit from my perspective is that I can solve this problem I am I am trying to call the mdls command from the Perl directory for each file, so that it can detect the last access time. The problem I have is that I have find from the file names I have an unsecured space which clearly does not like. What is an easy way to avoid all the white spots in my file names before going to mdls ? If this is a clear question, please forgive me. I'm fairly new to Perl

My $ top_dir = '/ version / hydrogen / FLAC'; The sub wanted {# Learn about sub-routines ($ file :: search :: name) {my $ curr_file_path = $ File :: Find :: name "\ N"; `Mdls $ curr_file_path`; Print $ _; }} Find (\ & amp; wishes, $ top_dir);

If you are certain that the file names are not newline (CR or LF) Then many unix shells cite backslash, and Pearl has the function to implement it.

  My $ curr_file_path = quotemeta ($ File :: Find :: name); My $ time = `mdls $ curr_file_path`; Unfortunately, it does not work for filenames with new names, since the shell follows a backslash, after which instead of backslash, a new line is used by removing the  both  letters. So to be really safe, use it:  
  Use string: ShellQuote; ... my $ curr_file_path = shell_quote ($ file :: search :: name); My $ time = `mdls $ curr_file_path`;  

It should work on some filename except the NUL character, which you should not actually use in filenames.

Both of these solutions are for Unix-style shells only if you're on Windows, the proper shell quote is very simple.


Comments