2007/10/23, Tom Phoenix <[EMAIL PROTECTED]>:
>
> On 10/23/07, Panda-X <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the reply. But seems I have no luck with that !
>
> Did you try readdir() or glob(), as I suggested? I can't see them in your
> code.
>
> --Tom Phoenix
> Stonehenge Perl Training
>


Yes, I did. Here's more code :

use Tk;
my $mw = MainWindow -> new();
$x = $mw -> getOpenFile ;
$mw -> Label ( -text=>$x ) -> pack();

print $x ;
###### so I got "Wide character in print at list.pl line 6."

# Not sure if that's meaningful, but it got the same error ( No such file or
directory )
$dir = $x; $dir =~ s/\/[^\/]+$//;
opendir D, $dir or $mw -> Label ( -text=> "$! ---> $dir " ) -> pack();
closedir D;

print glob $dir ;
# This gives nothing

open F , $x or $mw -> Label ( -text=> "$! ---> $x " ) -> pack();
$mw -> MainLoop;

###################################################

# This approach works! It shows all files, and I can open files.

my $hcode_path = "C:/Documents and Settings/Exile_Local/桌面" ; # Just treat
as a 2bytes char
opendir D, $hcode_path or $mw -> Label ( -text=> "$! ---> $hcode_path " ) ->
pack();
if  ( D  ) {
    print readdir D ;
    print "$/$/";
    open F, $hcode_path . "/index.html" or die $!;
     print while <F> ;
    close F;
}
closedir D;

###################################################

Since I got error "wide char" ... I guess that relates to utf8, and so I
wrote this in another script :

use Tk;
use utf8;

binmode(STDIN, ':encoding(big5)');
binmode(STDOUT, ':encoding(big5)');
binmode(STDERR, ':encoding(big5)');

my $mw = MainWindow -> new();
$x = $mw -> getOpenFile ;
$mw -> Label ( -text=>$x ) -> pack();

print $x;
###### This time, the path prints okay !

$dir = $x; $dir =~ s/\/[^\/]+$//;
opendir D, $dir or $mw -> Label ( -text=> "$! ---> $dir " ) -> pack();
closedir D;

print glob $dir ;

open F , $x or $mw -> Label ( -text=> "$! ---> $x " ) -> pack();
$mw -> MainLoop;

Beside I still got the "no such file or directory" error when I try to open
it,
the weir thing I don't understand is the glob() gives me this :

\x{00e6}" does not map to big5-eten at list.pl line 18.
"\x{00a1}" does not map to big5-eten at list.pl line 18.
"\x{008c}" does not map to big5-eten at list.pl line 18.
"\x{00e9}" does not map to big5-eten at list.pl line 18.
"\x{009d}" does not map to big5-eten at list.pl line 18.
"\x{00a2}" does not map to big5-eten at list.pl line 18.
C:/DocumentsandSettings/Exile_Local/\x{00e6}\x{00a1}\x{008c}\x{00e9}\x{009d}\x{00a2}

# I don't know why the spaces are sticked together, anyway.

############################################################

Just a note, I didn't assume users will select file from "Desktop" (in
Chinese) all the times,
so that maybe "C:\abc.exe", maybe
"C:/Folders/In/Other/Chinese/Char/Name/file.doc".

Thank you very much for any help.
Panda-X

Reply via email to