From owner-freebsd-hackers@FreeBSD.ORG Mon Jun 7 21:55:55 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 58DA016A4CE for ; Mon, 7 Jun 2004 21:55:55 +0000 (GMT) Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2AB4A43D2F for ; Mon, 7 Jun 2004 21:55:55 +0000 (GMT) (envelope-from dan@langille.org) Received: from wocker (wocker.unixathome.org [192.168.0.99]) by bast.unixathome.org (Postfix) with ESMTP id F3A283D34; Mon, 7 Jun 2004 17:55:52 -0400 (EDT) From: "Dan Langille" To: Chris Costello Date: Mon, 07 Jun 2004 17:55:53 -0400 MIME-Version: 1.0 Message-ID: <40C4AC29.10277.4951F0A6@localhost> Priority: normal In-reply-to: <1086643876.30998.2.camel@localhost.localdomain> References: <20031005111656.R18760@xeon.unixathome.org> X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body cc: freebsd-hackers@freebsd.org Subject: Re: testing for substrings in perl X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2004 21:55:55 -0000 On 7 Jun 2004 at 16:31, Chris Costello wrote: > On Sun, 2003-10-05 at 10:32, Dan Langille wrote: > > > I think it might just be easier to do a straight comparison of the first N > > characters of the two strings where N = length of the directory name. > > > > Any suggestions? > > You can do: > > if ($string =~ /\/?\Q$expr\E/) { > # ... matches ... > } > > \Q and \E are special metaquoting classes in perlre designed > specifically for cases like this. > > See 'man perlre' for more gory info. Who is lagged here Chris? Thanks for the reply though. FWIW, I suspect this was a FreshPorts-releated issue, and I think I was trying to solve this problem: is any file touched by this commit in the ports tree? foreach $value (@{$Files}) { my ($action, $filename, $revision, $commit_log_element_id) = @$value; print " processing $filename\n"; if ($filename =~ m|^/?ports/|) { $PortTreeCommit = 1; last; } } -- Dan Langille : http://www.langille.org/ BSDCan - http://www.bsdcan.org/