in reply to Re: directories and charsets
in thread directories and charsets

Thank you for the Traverse sub.

Frustratingly this sub(), when traversing my file tree, works fine, while my own humongous program doesn't and chokes on any filename that contains "non-ascii" characters, and I cannot as yet find what I am doing different.

Except that I am doing quite a bit of concatenation of strings and storage in intermediate variables, and I suppose that somewhere perl's smart handling of automatic internal string conversion to utf8-when-needed is biting me.

My real program scans several file trees, remembers in each the oldest file (storing the path in a table), then sorts the table on some formula, and passes the "best" path to another portion of the program for processing. It is in that other part of the program, when trying to use the path to open the file, that the problem occurs.
What I imagine is that somewhere along the line, what was initially read as a "bytes" entry, becomes an internal "utf8" string, and then open() or stat() do not recognise that filename anymore. Does that make sense ?

Replies are listed 'Best First'.
Re^3: directories and charsets
by Moron (Curate) on Mar 15, 2007 at 15:55 UTC
    The Traverse sub does plenty of assigning of the filenames too - readdir has to work on these first, then its loaded into $file then that forms part of $path, so it can't be that!

    I strongly suggest using perl -d on your program - you can then use the x, W, and b and r commands to track down what is really happening to this data.

    Apart from that, I would say that Traverse works because it's too simple not to :)

    -M

    Free your mind