Hi, I am a new member of this list and have many many questions I
would like to do... but also I am worried about being not on topic....
But, anyway, here is a issue I have been fighting with for weeks...
The next is a small prototype of an AddressBook I want to manage with
Perl. The data are in a small ASCII file and any word in it can be
the target of search. You only need to put one or more utf8 words in
the command line and then the script should shows to you the lines
that content them... (like grep, but potentially improvable). The
data file is in MacRoman encoding... The problem is:
1) How to manage utf8 high bytes words to be recognized (I would
like to find Ángeles Angeles ángeles or angeles with any of this
words!) I have used utf8::decode($_) but it seems not to work. "use
encoding utf8" seems to not affect in any way. When I use
utf8::decode of the @ARGV, it finds all, not filtering at all...
Thanks for any clue.
#!/usr/bin/env perl
#
# telefonos.pl
#
# me 2006-04-07
#
#
binmode STDOUT, ":utf8";
use encoding 'utf8';
my $listin = "/Users/me/Documents/documentos/Familia/Casa/Telistin.txt";
my $alphax = "/Applications/Alpha/AlphaX.app";
if ([EMAIL PROTECTED]) {
exec "open -a $alphax $listin";
}
if (! -e $listin){
print "strange! file not found: $listing \n";
exit 1;
}
open my $f, "<:encoding(MacRoman)", "$listin" or die "$listin no
abre: $!";
my @todo = <$f>;
close $f;
# PROBLEM
my @args = map {utf8::decode($_)} @ARGV;
my $re = join("|", @ARGV);
print grep(/$re/i, @todo), "\n";
# also look in the Apple AddressBook
foreach my $a (@ARGV) {
system("abtool $a");
}
---- ende