#!/usr/bin/perl -w


sub debug_unicode_string
{
    join("",
         map { $_ > 128 ?                      # if wide character...
                   sprintf("\\x{%04X}", $_) :  # \x{...}
                   chr($_)          
               } unpack("U*", $_[0]));         # unpack Unicode characters
}


if (scalar(@ARGV)!=1) {
    my $prog_name = $0;
    $prog_name =~ s/^.*(\\|\/)//;

    print STDERR "Usage: $prog_name dir\n";
    exit(1);
}

my $dir = $ARGV[0];

opendir(DIN,"$dir") 
    || die "Unable to open $dir";

my @files = grep { $_ !~ m/^\./ } readdir(DIN);

close(DIN);

#open(FOUT,">file-list.txt")
#    || die "Unable to open file-list.txt";

foreach my $f (@files) 
{
    print "Filename as is: $f\n";
    print "Filename debug: ", debug_unicode_string($f),"\n";

    my $dirsep = ($^O =~ /mswin/i) ? "\\" : "/";

    $dirsep =~ s@$dirsep$@@;

    if ( -e "$dir$dirsep$f" ) {
	print "   Perl can see file $dir$dirsep$f\n";
    }
    else {
	print "   Perl CANNOT see $dir$dirsep$f\n";
    }
#    print FOUT "$f\n";
}

#close(FOUT);
