But you're still going about it backwards. If TOTOIDS2 is the big file, 
you only want to read it once, if events is small (you read it to an 
array) make it a hash, massage the TOTIDS2 input and check it that way:
#!/usr/bin/perl -w
use strict;           # uncomment after running script several times 
# 
# Final result - sort data for each sensor according to event type 
# Declare input files 
my $input1="../tools/events.txt"; 
my $input2="../reports/totoids2.out"; 
# Open input files for use by the script 
open (EVENT, $input1)
  or die "can't open input1 $input1: $!"; 
my %events = map { $_ => 1 } <EVENT>;
open (TOTOIDS2, $input2) 
   or die "can't open input2 $input2: $!"; 
# Open output file for data 
open NIDS2, ">>../reports/ids2.out" or die "Cannot open $ids2 for append: 
$!"; 
# Sort events by type for TOTOIDS2 

while (<TOTOIDS2> ) {
   next unless /\|/;   # skip blanks
   my @vars = split(/\|/);  break up the line
# |2003-01-27 
# 
18:50:53|totoids2|PROXY:WEB-POST|198.96.134.61|207.46.110.23|25003|80|F||6|t 
   my ($port, $type) = split(/:/, $vars[2]);
   if ( $events{$port} ) {
     # got a valid entry
   }
}     # while <TOTOIDS2>


If you want them sorted by event types, you could open up 8 output files, 
one per event, and print to that, instead of the map, do:
my %events;
while (<EVENT> ) {
   chomp;
   my $event = $_;
   open($event, "> ../reports/$event.out" )
      or die "can't open event out $event: $!";
   $events{$event}++
}    # while <EVENT>

...
if ( $events{$port} ) {
   print $port $_;
}

}   # while <TOTOIDS>

and the concat the results or some such.  Going through files to big to 
read into mem umpteen times seems a mistake.

a

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5030

" ... even if you're mediocre/decent at perl [the cmecf] code is pretty 
confusing in certain areas ..." CB
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to