source: test-collections/trunk/filename-encodings/bin/script/dirlist.pl@ 23346

Last change on this file since 23346 was 23346, checked in by davidb, 11 years ago

Mistake in handling last directory separator fixed

File size: 1.1 KB
Line 
1#!/usr/bin/perl -w
2
3use strict;
4
5
6sub debug_unicode_string
7{
8 join("",
9 map { $_ > 128 ? # if wide character...
10 sprintf("\\x{%04X}", $_) : # \x{...}
11 chr($_)
12 } unpack("U*", $_[0])); # unpack Unicode characters
13}
14
15
16if (scalar(@ARGV)!=1) {
17 my $prog_name = $0;
18 $prog_name =~ s/^.*(\\|\/)//;
19
20 print STDERR "Usage: $prog_name dir\n";
21 exit(1);
22}
23
24my $dir = $ARGV[0];
25
26opendir(DIN,"$dir")
27 || die "Unable to open $dir";
28
29my @files = grep { $_ !~ m/^\./ } readdir(DIN);
30
31close(DIN);
32
33#open(FOUT,">file-list.txt")
34# || die "Unable to open file-list.txt";
35
36foreach my $f (@files)
37{
38 print "Filename as is: $f\n";
39 print "Filename debug: ", debug_unicode_string($f),"\n";
40
41 my $dirsep = ($^O =~ /mswin/i) ? "\\" : "/";
42
43 # Remove trailing directory separator
44 # (will be explicitly added in later on)
45 $f =~ s@$dirsep$@@;
46
47 if ( -e "$dir$dirsep$f" ) {
48 print " Perl can see file $dir$dirsep$f\n";
49 }
50 else {
51 print " Perl CANNOT see $dir$dirsep$f\n";
52 }
53# print FOUT "$f\n";
54}
55
56#close(FOUT);
Note: See TracBrowser for help on using the repository browser.