title: In what encoding does readdir return a filename?
body: <p>Here's a Perl script that I have expected to print <code>found</code> when executed:</p>
  
  <pre><code>#!/usr/bin/perl
  use warnings;
  use strict;
  use utf8;
  use Encode;
  
  use constant filename =&gt; 'Bärlauch';
  
  open (my $out, '&gt;', filename) or die;
  close $out;
  
  opendir(my $dir, '.') or die;
  while (my $filename_read = readdir($dir)) {
  # $filename_read = encode('utf8', $filename_read);
    print "found\n" if $filename_read eq filename;
  }
  </code></pre>
  
  <p>The script first creates a file with the name of the constant <code>filename</code>. (After running the script, I can verify the existence of the file with <code>ls</code> and the file is not created with "funny" characters.)</p>
  
  <p>Then the script iterates over the files in the the current working directory and prints <code>found</code> if there is a file whose name is equal to the file just created. This should obviously be the case.</p>
  
  <p>However, it doesn't (Ubuntu, bash, <code>LANG=en_US.UTF8</code>)</p>
  
  <p>If I change the constant to <code>Barlauch</code>, it works as expected and prints <code>found</code>.</p>
  
  <p>Uncommenting <code>$filename_read = encode('utf8', $filename_read);</code> does not change the behavior.</p>
  
  <p>Is there an explanation for this and what do I do have to do in order to recognize a filename with Umlaute in it?</p>