grep-like search with multiple file output? 
Author Message
 grep-like search with multiple file output?


>> Next question: How does one generalize this script to imitate AWK's
>> associative arrays?
>Why imitate them?  Perl has those too.  It just calls them hashes.

Not surprising considering perl's various debts to awk. "One of the
many cool things about Perl is that it is (at least) a semantic
superset of awk."--Randall L. Schwartz, "Learning Perl" ORA.

>>   pattern[++i] = "second pattern";outfile[i]=sprintf("out%05d",i)
>Hmm.  Those seem to be arrays, not hashes.  (numerical vs. string indices)

Don't quote me, but I believe awk always indexes on the string
representations. The following short program (MKS AWK) seems to bear
me out since all it prints is "456".

  test[1] = "123"
  test["1"] = "456"
  for (i in test) print test[i]


Now whether the implementation uses hashes, a linked list, or whatever
is another issue entirely. MKS seems to use an LIFO arrangement.
Thompson Automation insists on sorting at the time--one reason why
there versions compiled to massive, slower beasts.

>I think I'd use a pattern -> filehandle mapping with a hash here:
>(tested code)

This code is beyond my limited perl knowledge, so let's get back to
AWK. <g>

Maynard Hogg
#306, 4-30-10 Yoga, Setagaya-ku, Tokyo, Japan 158
Fax: +81-3-3700-7399

http://www.*-*-*.com/ (Japanese)
Unsolicited commercial electronic mail sent to this address will be
copyedited at a cost of US$200/hour (half-hour minimum).

Thu, 24 Feb 2000 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. In search of file searching script,output,every line occurance occurs

2. grep pat from multiple files

3. grep from a file to a output

4. Annoying problem opening multiple output files

5. piping output of multiple files

6. Reading multiple files and sending output to browser with Perl

7. Searching file contents in multiple directories?

8. Help searching multiple files

9. Efficiently searching multiple files

10. Search and Replace multiple files?

11. search and replace within files accross multiple lines ??

12. Help Searching through multiple files


Powered by phpBB® Forum Software