#!perl use Memoize; use Win32; use strict; sub sp { my $pn; die unless @_ and (($pn)=shift); warn "No such directory: \"$pn\"" && return undef unless -d $pn; ($pn = Win32::GetShortPathName($pn)) =~ s{\\}{/}g; substr ($pn, 1+rindex($pn,'/')) = lc substr ($pn, 1+rindex($pn,'/')); $pn } sub smorp { my ($piece) = @_; $piece = lc $piece eq 'system32' ? 'system32' : uc $piece eq 'WINDOWS' ? 'WINDOWS' : $piece; return "/".$piece; } memoize('sp'); memoize('smorp'); BEGIN { use Env qw/@PATH/; use vars ('@thePATH', '%Uniqueness'); } @thePATH = @PATH; @PATH = (); PONGO: for my $ele (@thePATH) { my $npiece; my @shattered = grep {$_} split /(?:[\\\/]+|:)+/ , $ele; my $backtog = index ($ele, ":") == 1 ? # is it : ? uc(shift @shattered).":" : $ele =~ m#[\\/]{2}# ? # or is it UNC ? "//".shift (@shattered) : do { die "UNRECOGNIZED PATHEL FORMAT" }; BLA: { $backtog .= smorp ($npiece) while @shattered && index (($npiece = shift @shattered)," ") == -1; unless (@shattered) { $Uniqueness{lc $backtog}++ and print "# DUPLICATE element skipped (\"$backtog\")\n" or print "$backtog\n"; # or add to an array, or whatever you need to do. next PONGO } # print "SPACES IN ${backtog}/${npiece}\n"; $backtog = sp("${backtog}/${npiece}"); redo BLA; } die "Reached code branch we should never see!"; }