Hello Ende,

On Apr 19, 2006, at 8:58 PM, ende wrote:


Wow! It is near the full solution! It is a pity it fails when you do not use accented chars!!

I tried again, and with the following script, it *seems* that you can use either non-accented characters or accented character:

#!/usr/bin/perl

use utf8;
use Encode;
use Unicode::Normalize;

binmode (STDOUT, ":utf8");

my $re = join("|", @ARGV);
$re = decode ("utf8", $re);
my $listin = "/Users/me/Documents/documentos/Familia/Casa/Telistin.txt";

open my $f, "<:encoding(MacRoman)", "$listin" or die "$listin no abre: $!";
while (<$f>) {
        chomp;
        if (/$re/i) {
                print $_, "\n";
        }
        else {
                my $temp = NFD($_);
                $temp =~ s/[\x{0300}-\x{036F}\x{0081}]+//g;
                print $_, "\n" if $temp =~ /$re/i;
        }
        if ($re !~ /^[\x{0000}-\x{007F}]+$/) {
                my $temp = NFD($re);
                $temp =~ s/[\x{0300}-\x{036F}\x{0081}]+//g;
                print $_, "\n" if /$temp/i;
        }
}
close $f;

You would call this script either:

perl Ende_test.pl angeles

or

perl Ende_test.pl ángeles

to get:

Ángeles
Angeles
ángeles
angeles

Is this what you would want...?

Note that I am not sure at all if this will work for all cases.

Best regards,

Nobumi Iyanaga
Tokyo,
Japan

Reply via email to