I should be able to solve this myself, but so far I haven't come up with any wiley approaches nor any magic combinations of keywords at Google:
How can I coerce Perl's \b pattern to recognize and respect accented characters?
my $land = 'Mexico';
my @words = split(/\b/,$land);
This does what you'd expect, and
scalar(@words)==1. However, if you change the 'e' in Mexico to an accented e (México), then it splits before and after the accented 'e', and
scalar(@words)==3.
use utf8; works as long as the literal appears in the text; reading in the text from outside the code doesn't work. E.g.,
$ perl -Mutf8 -e "print join(q{,},split(/\b/,\$ARGV[0])),qq{\n}" méxic
+o
m,é,xico
$ perl -Mutf8 -e "print join(q{,},split(/\b/,q{méxico})),qq{\n}"
Wide character in print at -e line 1.
méxico
| -- |
| Jeff Boes |
| Database Engineer |
| Nexcerpt, Inc. |
|
|
|
...Nexcerpt...Connecting People With Expertise
|
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.