add apostrophes with regular expression in perl -


I'm searching the directory with command ls -ld /path1/*.ext1 / path2 / *. Ext2 , e.t.c.

Sometimes, files have special characters in the name: ) , (, etc.).

For this reason, I want to add aproprows in every search directory.

For example:

  $ filter = "ls -ld / Path1 / * ext1 / path2 / * ext2 "; (1) $ filter = ~ ...; (2)   

After the regular expression is applied, the result should be:

  ls -ld '/ path1 / * ext1' '/ path2 / * ext2' (with apostrophes)   

What is a regular expression (2)

    

$ Filter = ~ s! (\ S +)! '$ 1'! G;

Better way to do this:

  while (globe ("/ path1 / * ext1 / path2 / * ext2") {process_file ($ _);}   

Regards,

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -