Awful!!  You did it!  Although I don't understand well the regexps..

The code only need very small fixes

        1) To exit when no args
2) Try to not identify ñ with n (but this is a bug in the collating in utf..., :)


Really impressed and very grateful to you!


This will be part of my AddressBook terminal script and a now a model to learn from. Thanks.




El 19/04/2006, a las 15:57, Nobumi Iyanaga escribió:

#!/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;


---- ende



Reply via email to