Your code contains an error. Even if it compiled, it would not search for what you want. The qr'red strings are interpolated as
(?-xism:$string). So you would actually search for e.g.
/\btak[(?-xism:ABVH)]/, what i'm sure is not what you want.
Consider the following code (i can give an example in Cyrillic-Windows-1251, but i don't know if it's compatible with Belorussian variant):
my $letters = '[a-zA-Z]'; # try - maybe the character range will work
+for you. It works in Cyr-1521, but does not in KOI8-R
my @wordpatterns = map { qr/(?<!$letters)(\Q$_\E$letters*)/ } qw(tak h
+et hen toj);
while (my $next_line = <$FH>) {
foreach my $pattern (@wordpatterns) {
my $count_words = ($next_line =~ s/$pattern/>$1</gi);
}
}
The code is untested, but must do the Right Thing in much better way than yours. It re-uses the generated regexes and may make processing of large amounts of data noticeably faster.
One more note—the /i switch won't work for Cyrillic encodings without carefully set locale. The behaviur of boundaries (\b) is wrong, if the locale is wrong—so i removed them from my regex too.
s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print
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.