Just another Perl shrine | |
PerlMonks |
Re: Words in Wordsby chrestomanci (Priest) |
on Sep 30, 2011 at 20:23 UTC ( [id://928908]=note: print w/replies, xml ) | Need Help?? |
Instead of using regular expresson to check if one word is a substring of another, why not use index instead. It is a simple function that returns the offset of the shorter string within the longer one if it is a substring, or -1 it it is not. The kind of thing you expect to find in the string libaries of programing languages without regular expresson support, but so rarely used by perl programmers that most of us have forgotten the function exists.
In Section
Seekers of Perl Wisdom
|
|