NAME

Phrase.pl - full text searching perl script


SYNOPSIS

usage:

  perl Phrase.pl

Show brief usage Please refer ``brief usage'' for options.

  
  perl Phrase.pl Search+Phrase-NotThis [Options]  >outfile.htm

Search for paragraphs that contain ``Search'' and/or ``Phrase'' but not ``NotThis''

  
  perl phrase.pl "th(is|at)+th[eo]se" -e txt  >outfile.htm

Search all the .txt files for paragraphs that contain ``this'' and/or ``that'', ``these'', ``those''

  
  perl phrase.pl "\bc\b-\bc\+\++pascal"

If you know perl, than you would know \b. This search means search for whole-word-only C and Pascal but does not want C++


Description

I keep two search tools for my daily use

  GREP form Borland
  TS from Norton Utility

I use grep extensively. It does excellent job when I search for program lines. But it can not highlight the keywords found. And, it lacks the context when I search for an idea or something.

So I turn to TS from time to time. It overcomes the above two grep's drawbacks, but it introduces other nuisances: It requires too much user interaction. I have to press far too many 'Y's before I can skip a file I am not care. And I can't refer back what I've searched.

So, here is my solution to it -- My phrase search.pl, A perl script that grep on certain files in certain dir for certain phrases on paragraph based. FREE!

Phrase.pl: A full text searching perl script. Paragraph based search for keyword phrases output (into html file) with found keyword emphasized. Support regular expressions and perl extended regular expressions. Smart algorithm that combine ``and'' ,``or'' together. Sufficient and efficient.


Algorithm

scan every file (include all that in the subdir)

search on *paragraph basis* instead of line basis on each file.


Perl dodir Bug

How nice. I can embed what I've tried in code without disgrade anything. The following results come from my interactive perl learning script http://www.geocities.com/SiliconValley/Lakes/2659/lp.htm

        # Bug ? opendir can't work when specified with any '/' or '\'
        # can only work with . or .. and even : ...

 ([undefined]) ? opendir(DIR,"e:/.")
 (1) ? closedir(DIR)
 (1) ? opendir(DIR,'e:/.')
 (1) ? opendir(DIR,'e:/')
 ([undefined]) ? opendir(DIR,'e:\')
 Can't find string terminator "'" anywhere before EOF
 ([undefined]) ? opendir(DIR,'e:\\')
 ([undefined]) ? exit


Sample

Uhmm, I wonder how to use the newly introduced function chomp. No problem, use my Phrase.pl to search for sample usages. Let's search the current directory for .pl programs.

        perl phrase.pl chomp -e pl >chomp.htm

Here comes the result. It is really quick! http://www.geocities.com/SiliconValley/Lakes/2659/chomp.htm


AUTHOR

Sun Tong <suntong@goecities.com>


COPYRIGHT

Copyright (c) 1997 Sun Tong. All rights reserved.

This program is FREEWARE, but requires you to register -- just send me an email :-). I want to know where my program goes.


REGISTER & OTHER INFOMATION

Register syntax:

 To:      suntong _at_ geocities -dot- com
 Subject: Register Phrase <Your Country> <Your state>
 Body:    <Maybe blank, Any comments, bug reports, etc, are
          welcome>

Comments:

You are welcome to my home page http://www.geocities.com/SiliconValley/Lakes/2659/ . You'll find more FREE tools there.

This page is automatically generated by pod2html from perl -- http://www.perl.com


TODO