in reply to Re: Searching text files
in thread Searching text files

you can get a <...> grep.exe for windows as well...

Why bother, when windows has a native tool that serves a similar purpose:

my $result = `findstr $phone_num file1 file2 file3`; if ( $result ) { print "DO NOT CALL $phone_num\n"; } else { print "You can annoy $phone_num with your gratuitous cold calling\n" +; }

Replies are listed 'Best First'.
Re^3: Searching text files
by davido (Cardinal) on Sep 14, 2006 at 19:11 UTC

    grep and findstr are both O(n) linear searches. Maybe I'm missing something here, but I think that's what the OP is trying to avoid; a linear search that takes O(n) time to fail.


    Dave

      forget O(n) etc. the original poster was slurping the whole files into memory, which was the cause of the slowness. grep will match the number in the 3 files (several megs total) in about a second....which surely meets the criteria for response time. the poster is a beginner, so would be best for them to have a one liner with a 1 second response time..rather than complicated code with at best 0.5 second response time.
      the hardest line to type correctly is: stty erase ^H
      grep and findstr are both O(n) linear searches...

      Err, yes. But could you explain why you posted this as a reply to my node, which is explicitly tagged as a reply to aquarium rather than a solution to the OP's problem?