B
Broke
Hello,
I am a beginner so please be indulgent.
I wanted to make a sort of dictionary given a text french file.
So I wrote the following script.
Everything is OK but the ordered list comes in US ASCII encoding.
How to make it work for accented letters?
Any help will be appreciated.
Here is my humble script.
=======
#!/usr/bin/perl -w
use warnings;
local $/;
use locale;
use utf8;
$file = '/Users/Broke/Desktop/data.txt';
open (IN, $file) or die "$file not found\n : $!\n";
@data = ();
%seen = ();
while (<IN>) {
foreach $word (m/(\b.+?\b)/gi) {
unless ($seen{$word}) {
$seen{$word} = 1;
push(@data, $word);
}
}
}
close (IN) or die "Can't close $file : $!\n";
@data = sort(@data);
@data = map $_ . "\n", @data;
open (OUT, ">/Users/Broke/Desktop/out.txt") or die "Can't create\n :
$!\n";
select (OUT);
print @data;
close (OUT);
========
B.
I am a beginner so please be indulgent.
I wanted to make a sort of dictionary given a text french file.
So I wrote the following script.
Everything is OK but the ordered list comes in US ASCII encoding.
How to make it work for accented letters?
Any help will be appreciated.
Here is my humble script.
=======
#!/usr/bin/perl -w
use warnings;
local $/;
use locale;
use utf8;
$file = '/Users/Broke/Desktop/data.txt';
open (IN, $file) or die "$file not found\n : $!\n";
@data = ();
%seen = ();
while (<IN>) {
foreach $word (m/(\b.+?\b)/gi) {
unless ($seen{$word}) {
$seen{$word} = 1;
push(@data, $word);
}
}
}
close (IN) or die "Can't close $file : $!\n";
@data = sort(@data);
@data = map $_ . "\n", @data;
open (OUT, ">/Users/Broke/Desktop/out.txt") or die "Can't create\n :
$!\n";
select (OUT);
print @data;
close (OUT);
========
B.