Matching stuff

Tom Phoenix rb-pdx-pm at
Wed Jun 5 21:09:58 CDT 2002

On Wed, 5 Jun 2002, Joshua Keroes wrote:

> if ( $service =~ /$rule/ ) {

That's fine much of the time. But if there's a chance that $rule could
have metacharacters, or could be empty, you'll want to use \Q in front of

> if ( index $service, $rule ) {

Eek! No, that's not right. Remember that index will return 0 (which is
false) if the substring is found at the beginning of the string, and -1
(which is true) if it's not found at all. You must have meant this:

    if (-1 != index $service, $rule) {

I don't think you were trying to be that silly... until the later items.



More information about the Pdx-pm-list mailing list