in reply to Help with Regular Expressions

Or there is the base module File::Find. $_ always holds the current file/directory name as it runs through the directory tree. I think it's what you should use, no need for regexes.
An excellent intro is here: Beginners guide to File::Find

I'm too lazy to be proud of being impatient.

Replies are listed 'Best First'.
Re^2: Help with Regular Expressions
by FFSparky (Acolyte) on Apr 10, 2012 at 19:56 UTC
    nemesdani,

    Actually, I am using that module, and unless I am missing something, when it's a directory the $_ will either contain the full path, or the directory name of the current directory.

    using my example above I would get a list like:

  • DirD
  • DirE
  • Enabling no_chdir => 1 will produce

  • \\DirA\DirB\DirC\DirD
  • \\DirA\DirB\DirC\DirD\DirE
  • Which I can then use the File::Spec->abs2rel and get \DirD\DirE

    The reason I am after \DirD\DirE is I want to then append this to another base path to see if a file / directory exist in that location

      Oh, I slightly misunderstood your question, forgive me. In this case, I don't know any better solution than Riales', and I still think an OS-independent regex would be too much trouble for this particular problem.


      I'm too lazy to be proud of being impatient.