|
|
| Do you know where your variables are? | |
| PerlMonks |
Re: character offset to word offsetby GrandFather (Saint) |
| on Sep 08, 2008 at 20:51 UTC ( [id://709872]=note: print w/replies, xml ) | Need Help?? |
|
There are a couple of things to think about here. You need to figure out how you are going to store the word spans (where do they come from btw?). Deciding just what is a word can be tricky (e.g. for example). When editing involves changing the length of whatever is being edited it is often better to work backwards so that you don't change the indexes for subsequent edits. The following somewhat golfed code (don't hand it in to your teacher) counts words by counting the spans of spaces between them:
Prints:
Perl reduces RSI - it saves typing
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||