Jeff 'Japhy' Pinyan wrote:
On Aug 2, Alan C. said:

#!/perl/bin/perl -w
use strict;
#map & join from @ARGV into $pattern snipped
<snip>

#!/perl/bin/perl -w
#Win32 d:\perl\bin\perl.exe
use strict;
@ARGV=qw/doc sort/;
my $pattern;
# next is the original it's without word boundary
#    $pattern=join('',map{"(?=.*$_)"[EMAIL PROTECTED]);
# next is foiled attempt to add word boundary
#    $pattern=join('',map{"(?=.*\b$_\b)"[EMAIL PROTECTED]);
# next does makes the word boundary work
    $pattern=join('',map{"(?=.*\\b$_\\b)"[EMAIL PROTECTED]);
print "$pattern";
#directory files foreach file to be searched snipped
#if (s/^H=($pattern)/$1/io) {
#     print "$fil:$_" ;
#     }

In the map and join line I tried \b

(?=.*\bdoc\b)

but the pattern got messed up, part of the pattern got cut off.


If the map & join line is the one you worked on, why did you omit it from
your code?

one them late in the day hiccup during the processing of the cpu that sits up atop my neck. Temporary judgement error, etc. I now enclosed the (problematic line of) code up above.


Chances are, that's where the problem lies.  Perhaps you used
doubled quotes around that part of the pattern?

Yes did have double quotes.


my $pattern = join "", map "(?=.*\b$_\b)", @ARGV;

Is that what your code looks like?

#code that messed up, chopped off part of regex pattern my $pattern; $pattern=join('',map{"(?=.*\b$_\b)"[EMAIL PROTECTED]);

If so, the problem is that \b, in
double quotes, means "backspace".  In order to get around this, you'll
need to either double the backslash, or use different quoting:

  my $pattern = join "", map "(?=.*\\b$_\\b)", @ARGV;
  my $pattern = join "", map '(?=.*\b' . $_ . '\b)', @ARGV;

For reasons that are probably obvious, I prefer the first of those
approaches.

my $pattern; $pattern=join('',map{"(?=.*\\b$_\\b)"[EMAIL PROTECTED]);

How about this? It finds doc like I want, not document. I don't know why, but it has 1 more set of parenthesis than yours and also has curly brackets that yours doesn't.

Now that you pointed it out, I (1st time 4 me) found backspace in the "Programming Perl" book. Found in a table of "Alphanumeric Regex Metasymbols"

The context must a done it. Otherwise, all that I (until now) knew was that \b signifies word boundary. Thanks!

--
Alan.


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to