perl output - failing in printing utf8 text files correctly
<p>so i have utf8 text files, which i want to read in, put the lines into an array, and print it out. But the output however doesn't print the signs correctly, for example the output line looks like following: </p>

<blockquote>
  <p>"arnÅ¿tein gehÃ¶rt grÃ¤flichen "</p>
</blockquote>

<p>So i tried testing the script by one line, pasted directly into the perl script, without reading it from file. And there the output is perfectly fine. I checked the files, which are in utf8 unicode.  Still the files must cause the output problem (?). </p>

<p>Because the script is too long, i just cut it down to the relevant:
( goes to directory, opens files, leads the input to the function &amp;align, anaylse it, add it to an array, print the array)</p>

<pre><code>#!/usr/bin/perl -w
use strict;

use utf8;
binmode(STDIN,":utf8");
binmode(STDOUT,":utf8");
binmode(STDERR,":utf8");

#opens directory
#opens file from directory
 if (-d "$dir/$first"){
  opendir (UDIR, "$dir/$first") or die "could not open: $!";
  foreach my $t (readdir(UDIR)){
   next if $first eq ".";
   next if $first eq "..";

   open(GT,"$dir/$first/$t") or die "Could not open GT, $!";
   my $gt= &lt;GT&gt;;
   chomp $gt;

   #directly pasted lines in perl   - creates correct output
   &amp;align("det man die Profeſſores der Philoſophie re- ");

    #lines from file    - output not correct
    #&amp;align($gt);
    close GT;
    next;

  }closedir UDIR;
}
</code></pre>

<p>Any idea ? </p>