Matching stuff

Joshua Keroes joshua_keroes at eli.net
Thu Jun 6 02:03:52 CDT 2002


On (Wed, Jun 05 19:09), Tom Phoenix wrote:
> 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
> it.
> 
> > 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.

I stand corrected. No, those first two were honest help. All the latter ones; well those were the silly ones. :-)

Serves me right for not running anything first.

-J


TIMTOWTDI



More information about the Pdx-pm-list mailing list