I have a module which is called by a command-line shell, or by a Tk GUI shell. In both cases the shells just collect parameters and the module does the work which includes building a list of files to process.

My problem is files or directories with non Latin-1 chars in them. When run in the command line context, such files are "found". When run within the Tk GUI context, they are not!

I inserted a debug print into the File::List->new processing loop to display the directories being processed, with an else to print those which were neither -d, nor -f. The modified File::List->new is shown below (my mods in column zero):

sub new { my $class = shift; my $base = shift; my $self = {}; bless $self, $class; # store my base for later $self->{base} = $base; $debug && print "spawned with base [$base]\n"; # read in contents of current directory opendir (BASE, $base); my @entries = grep !/^\.\.?\z/, readdir BASE; chomp(@entries); closedir(BASE); for my $entry (@entries) { print "DEBUG: processing '$base/$entry'\n"; # if entry is a directory, launch a new File::List to explore it # and store a reference to the new object in the dirlist hash if (-d "$base/$entry") { $debug && print _trace(),"following directory $base/$entry\n"; my $newbase = new File::List("$base/$entry"); $self->{dirlist}{ $entry } = $newbase; } # if entry is a file, store it's name in the dirlist hash elsif ( -f "$base/$entry"){ $debug && print _trace(),"Found file : $base/$entry\n"; $self->{dirlist}{ $entry } = 1; } else { print "DEBUG: '$base/$entry' is not -f nor -d\n"; } } return $self; }

The console output in command-line mode is:

DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/folder.jpg' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/VIDEO_TS' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/VIDEO_TS/fanart.jpg' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/VIDEO_TS/VIDEO_TS.TAG' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/backdrop.jpg' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/mymovies.xml' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/folder.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/index.TAG +' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/fanart.jp +g' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/backdrop.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/mymovies.xml'
In Tk GUI mode we get:
DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)' DEBUG: '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1962)' is no +t -f nor -d DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/folder.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/index.TAG +' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/fanart.jp +g' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/backdrop.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/mymovies.xml'

Note that the path with the utf-8 char in it is not recognized as a directory. Apparently *Something* introduced by the Tk environment is preventing the -d test from returning true.

I've tried a few things, but to no avail. Suggestions or helpful references MOST welcome!


In reply to File::List, UTF-8, and Tk by ron7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.