Write an ordinary Perl program that filters the text, then measures its length using the built-in substr function.
You're trying to solve an everyday text processing problem in a very peculiar and unconventional way. Writing a custom substr function to measure a particular kind of "string" is like inventing a bathroom scale that knows when your hair is wet and you haven't removed your shoes, yet accurately measures your bone-dry, barefoot weight.
I'm curious: Do you want to measure the lengths of the strings in bytes, in encoded characters (Unicode code points), or in real-world characters (Unicode extended grapheme clusters)?
CLARIFICATION: I admit I sort of conflated substr and length in this post. My excuse is that I was fixated on the words "count" and "one character" in tej's restatement of his Y problem:
Suppose i have string that contains tags like "<bold>" it should not count this tag. If string has something like "<194>" I want substr to consider it as one character.
In reply to Re^3: substr function
by Jim
in thread substr function
by tej
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |