[Gllug] Perl scripting challenge
Richard Jones
rich at annexia.org
Wed Oct 4 15:32:17 UTC 2006
This is my best shot:
----------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
foreach my $path (@ARGV) {
opendir DIR, $path or die "$path: $!";
my @files = readdir DIR;
my %dups = ();
foreach (@files) {
my $lower = lc $_;
my @a = exists $dups{$lower} ? @{$dups{$lower}} : ();
push @a, $_;
$dups{$lower} = \@a;
}
foreach (keys %dups) {
my @a = @{$dups{$_}};
if (@a > 1) {
print join(", ", @a), "\n";
}
}
}
----------------------------------------------------------------------
I'm sure it could get a lot shorter than that.
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
Merjis blog - http://blog.merjis.com - NEW!
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list