Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 11:18 on June 26, 2006


"Ocean fishing" in the perl script.

Forums someone had asked in a very large number of documents to search the catalog, it is obvious then that we are most concerned about is performance. C to do the best you might say, but the good performance of the algorithm may be able to meet the requirements under the shell. Here we find the things we have to assume that occurs only once a year. Then :
1. We ought to give up the search to find matching other documents;
2. Due out in the documents are significant, withdrawing from the current process in matching documents found in the search.
If the shells do directly, it may get into the command line or length restrictions on the number of parameters of the problem, if xargs retooling order, who have to deal with some very difficult problems. So simply use perl to write a please correct me :
[code]#!/usr/bin/perl
Die "usage : $ 0 path pattern\n" unlessARGV ====== 2;
($path, $pattern) =@ARGV;
$, = " ";
Print $path;
Opendir (DH, $path) or die "can not open dir!";
While ($file = readdir (DH)) (
Next if (!open (FH that. " /. " $file));
While ( "FH>) (
$file Print $ 1 if (m/ ($pattern) /);
If ($ 1) (
Printf STDERR "found in %d!\nexiting %s line. . . \n "$file, $.;
Exit 0 # change this to "next;" (no ") if you want to find in other files
        }
    }
Close (FH);
}
Closedir (DH);
Print STDERR "not found. "
Exit 1[/code]

Discussion :
1. If we find out things will not occur once, but not several times in each paper, we must continue to search for other documents. Notes of the above will bring his script read :
[code]next;[/code]
2. If the plots of each document may also arise, then there is nothing I can do tricky, but notes his band will be deleted. You had better go write C procedures, or other features found in the search algorithm to improve the speed.


-->
Wow. . . Fine, fine
Collection [img]http://www.lslnet.com/linux/#images/smilies/em02.gif[/img]



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com