Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^5: In search of a better way to trim string lengthby dragonchild (Archbishop) |
on Jul 19, 2004 at 19:37 UTC ( [id://375668]=note: print w/replies, xml ) | Need Help?? |
The issue arises from what constitutes a "word". The basic definition is @words = split ' ', $line;, which works in most cases. However, it's arguable that a better definition could be @words = $line =~ /(\b\w+(?:['-]\w+)\b)/;. Of course, you're now depending on the definition of \w, which includes underscore and doesn't include apostrophe or hyphen. *shrugs* YMMV a huge amount. Parsing any natural language is much harder than parsing Perl which, as everyone knows, can't be done in Perl.
Good luck! I mean it. ------
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose I shouldn't have to say this, but any code, unless otherwise stated, is untested
In Section
Seekers of Perl Wisdom
|
|