Re: testing for substrings in perl

2004-06-07 Thread Dan Langille
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:

Re: testing for substrings in perl

2003-10-05 Thread Matthew Seaman
On Sun, Oct 05, 2003 at 11:32:11AM -0400, Dan Langille wrote: > Hi, > > I have a perl regex to test if a file resides under a particular > directory. The test looks like this: > > if ($filename =~ $directory) { ># yes, this filename resides under directory > } > > This is working for most c

Re: testing for substrings in perl

2003-10-05 Thread Mikko Työläjärvi
On Sun, 5 Oct 2003, Dan Langille wrote: > Hi, > > I have a perl regex to test if a file resides under a particular > directory. The test looks like this: > > if ($filename =~ $directory) { ># yes, this filename resides under directory > } > > This is working for most cases. However, it fails

Re: testing for substrings in perl

2003-10-05 Thread Fred Souza
> 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 might try index() or substr(). Fred -- "MOTHER: Half a word." pgp0.pgp Description: PGP signature

testing for substrings in perl

2003-10-05 Thread Dan Langille
Hi, I have a perl regex to test if a file resides under a particular directory. The test looks like this: if ($filename =~ $directory) { # yes, this filename resides under directory } This is working for most cases. However, it fails is the directory contains a +. For example: $filename =