Click to See Complete Forum and Search --> : How do you check whether a file/directory starts with a . ?


henryh
07-29-2004, 12:37 PM
I am looping through a directory for all subdirectories and files and I don't want to affect hidden files, which start with a ".".
Been trying to use the m// operator with inexact matches, but I don't know how to get it to return true or false.
Here is my code
# -------------------------- CODE --------------------------------

if ($Name =~ /^./) { };
# Don't do anything with it if it starts with a .

# ------------------------ END OF CODE ---------------------------

Thank you for reading. Any help would be greatly appreciated.

CyCo
07-29-2004, 12:44 PM
...you'll need to escape the "dot"


if ($Name =~ /^\./) { };