D
DavidK
Hello,
I am trying to process some Greek text using Perl. Strangely, I can
print out the text properly but when I try to assign the text to a
variable or do some processing, it fails.
The data file is:
1 και
2 να
My program is:
#!/usr/bin/perl -w
use strict;
use encoding "greek";
my %symbols = ();
open(FILE, "$file");
while (my $line = <FILE>) {
chomp($line);
my @fields = split(/\s+/, $line);
my $num_fields = @fields;
if ($num_fields == 2) {
my $freq = shift(@fields);
my $word = shift(@fields);
print "$word\n";
my @letters = split(//, $word);
foreach my $letter (@letters) {
$symbols{$letter} = 1;
print "$letter -> $letter_test\n";
}
print "\n";
}
}
The output is:
και
� ->
� ->
� ->
� ->
� ->
� ->
να
� ->
� ->
� ->
� ->
I've done some reading on the web and I still can't figure out what's
happening.
I'd appreciate any help. Thanks!
I am trying to process some Greek text using Perl. Strangely, I can
print out the text properly but when I try to assign the text to a
variable or do some processing, it fails.
The data file is:
1 και
2 να
My program is:
#!/usr/bin/perl -w
use strict;
use encoding "greek";
my %symbols = ();
open(FILE, "$file");
while (my $line = <FILE>) {
chomp($line);
my @fields = split(/\s+/, $line);
my $num_fields = @fields;
if ($num_fields == 2) {
my $freq = shift(@fields);
my $word = shift(@fields);
print "$word\n";
my @letters = split(//, $word);
foreach my $letter (@letters) {
$symbols{$letter} = 1;
print "$letter -> $letter_test\n";
}
print "\n";
}
}
The output is:
και
� ->
� ->
� ->
� ->
� ->
� ->
να
� ->
� ->
� ->
� ->
I've done some reading on the web and I still can't figure out what's
happening.
I'd appreciate any help. Thanks!