| Line | |
|---|
| 1 | #!/usr/bin/perl
|
|---|
| 2 | # Finds the files that have the same name, case insensitively,
|
|---|
| 3 | # in the current directory and its subdirectories
|
|---|
| 4 |
|
|---|
| 5 | use warnings;
|
|---|
| 6 | use strict;
|
|---|
| 7 | use File::Find;
|
|---|
| 8 |
|
|---|
| 9 | my %files;
|
|---|
| 10 | find(sub {
|
|---|
| 11 | my $name = $File::Find::name;
|
|---|
| 12 | # Assumes that the path separator is exactly one character.
|
|---|
| 13 | $name =~ s/^\.\..//;
|
|---|
| 14 | push @{$files{lc $name}}, $name;
|
|---|
| 15 | }, '.');
|
|---|
| 16 |
|
|---|
| 17 | my $failed;
|
|---|
| 18 |
|
|---|
| 19 | foreach (values %files) {
|
|---|
| 20 | if (@$_ > 1) {
|
|---|
| 21 | print join(", ", @$_), "\n";
|
|---|
| 22 | $failed++;
|
|---|
| 23 | }
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | print "no similarly named files found\n" unless $failed;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.