Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 07 Jun 2004 17:55:53 -0400
From:      "Dan Langille" <dan@langille.org>
To:        Chris Costello <chris@machined.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: testing for substrings in perl
Message-ID:  <40C4AC29.10277.4951F0A6@localhost>
In-Reply-To: <1086643876.30998.2.camel@localhost.localdomain>
References:  <20031005111656.R18760@xeon.unixathome.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40C4AC29.10277.4951F0A6>