perl_mystery has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I need a starting point to achieve the following tasks.Can any one pls give me a sample code to start with?

1.Get all the folder and file names recursively in a directory 2.search recursively for the names obtained in step#1 in a directory and report those filenames (of the searched name or folder in step#1) which has case-sensitivity issues

  • Comment on Finding only names in a dir and searching for case issues

Replies are listed 'Best First'.
Re: Finding only names in a dir and searching for case issues
by toolic (Bishop) on Mar 16, 2011 at 19:22 UTC
    Algorithm:
    • Use File::Find (Core) or File::Find::Rule (CPAN) to create a list of files.
    • For each file, get the basename of the file. Store the lc of the basename as a key in a hash, the value being the full file name.
    • If a hash key already exists, print out both full file paths.

      I am not sure how this helps,for example,lets say there a file name "Data.h" in our list of files,and there is a file "foo.c" which has #include "data.h"(observe the case-sensitivty for letter "d").Now I want to print the file name and the #include line.Can anyone give a sample code or atlease suggest a correct algorithm?

        Sounds like you're looking for functionality like this:
        ls -1 | while read filename; do grep -ir "$filename" * | grep -v "$fil +ename" ; done
        (However, this is not perl :)
Re: Finding only names in a dir and searching for case issues
by jfroebe (Parson) on Mar 16, 2011 at 19:03 UTC

      Thanks for the response.I did check-out that but I am not entirely sure how to use it to catch the case-sensitivity thing.

      I know I can use file::find to get the files and directory names,how to take care of step#2?