http://www.perlmonks.org?node_id=356771

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

How to list out all the files with same filename? I am totally newbie for perl.. No idea at all. Somebody can help me? Thank you

Replies are listed 'Best First'.
Re: Listing all files with same filename
by davido (Cardinal) on May 27, 2004 at 00:54 UTC
    Do you mean all files for which there exist duplicates on the same filesystem?

    File::Find is a startingpoint, and using a hash of lists to hold filenames as keys and paths in the list of values for each key.


    Dave

Re: Listing all files with same filename
by Hero Zzyzzx (Curate) on May 27, 2004 at 01:45 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Listing all files with same filename
by Abigail-II (Bishop) on May 27, 2004 at 09:06 UTC
    What's your definition of "same filename"? Depending how you look at it, it might be impossible to have two files with the same filename (well, two files on the same system with the same name).

    Abigail

Re: Listing all files with same filename
by TomDLux (Vicar) on May 27, 2004 at 03:41 UTC

    Consider the frequently asked question, How do I find lines which exist in both file1 and file2? Some of the answers to this question will be useful to you when reading in a bunch of file names and paths from File::Find and trying to detect which ones are duplicates.

    --
    TTTATCGGTCGTTATATAGATGTTTGCA

Re: Listing all files with same filename
by tucano (Scribe) on May 27, 2004 at 01:03 UTC
    ...
    just filename* <- this '*' match any char from here
Re: Listing all files with same filename
by titto (Initiate) on May 27, 2004 at 02:46 UTC
    Yup, this is my degree course homework. And I'm doing distance learning so it is impossible for me to ask any tutor. I have to do research on my own. Hope somebody here can help me out. Any useful site link about perl to me? Thanks and I will try to work it out with File::find command.

      I'm not implying that asking for help on homework is wrong. . .

      I don't think anyone is opposed to giving you direction (and you've gotten some already: use File::Find) IF you've shown that you've put in the effort. This usually means showing some code you've written in an attempt to solve the problem.

      What have you tried? Googling for "File::Find tutorial" turned up several promising links.

      -Any sufficiently advanced technology is
      indistinguishable from doubletalk.

      My Biz

      There are many useful sites about perl. If you're meant to be learning perl as part of your degree (hooray for enlightened universities!) then your tutor should have told you a few useful places to start. If you have a choice of language to use, then use whichever you are most familiar with, rather than learning perl just for this task.