scootstah Posted June 16, 2012 Share Posted June 16, 2012 How would case-sensitivity (vs. non) be handled? case insensitive (simple match) $haystack^=$needle (starts with) $haystack$=$needle (ends with) case sensitive (exact) $haystack^==$needle (starts with) $haystack$==$needle (ends with) No, I don't like that. That is just confusing given the syntax for identical comparison operators. And I think introducing another "variant" is just going to make operators unnecessarily complex. Operators are supposed to be simple. Rather than a starts with / ends with operator I'd rather see a regex match operator, such as =~ or something. Then you could accomplish not only the starts/ends with easily but other patterns too. //starts with $str =~ /^some string/; //ends with $str =~ /some string$/; Just toss the i modifier on for case insensitive. It'd just be nice syntactical sugar though, using the appropriate functions is fine. Now that is a great idea. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.