This is frustrating. I've done everything here, and I can't get this script to work. It takes summarized log entries (in the form of "Username\tDate\tlogins\tbad disconnects\tserver\n") and SHOULD sort them by date, then username, and if both are the same, combine the records. I've even gone through this line by line and tracked the variables. Because I got it to work that way (on 'paper', but not running) I'm sure I've done something stupid, be it simple or complex. By the way, I've used this method because I will be dealing with 300mb files in the future. For now, I'm using this 35 line example, and getting "S 9/5/97 554 1 0 c3 " as a response. - Strider Input File (sum.tab) : S 9/5/97 554 1 0 c3 t 9/2/97 14403 1 0 w2 t 9/3/97 14404 1 0 w2 t 9/5/97 33059 3 0 w2 c 9/1/97 652 1 0 b4 c 9/2/97 24123 13 2 b4 c 9/3/97 5758 6 1 b4 c 9/4/97 23898 17 0 b4 c 9/5/97 104 1 0 b4 r 9/2/97 355 1 0 w2 G 9/2/97 1897 1 0 c3 s 9/5/97 1539 1 0 o2 a 9/2/97 2569 1 0 p6 a 9/3/97 1273 1 0 o2 a 9/4/97 2460 1 0 p6 a 9/5/97 4465 1 0 p6 r 9/2/97 1678 1 0 p6 r 9/3/97 1238 1 0 p6 r 9/4/97 446 1 0 p6 s 9/2/97 1840 1 0 w2 s 9/4/97 1326 1 0 b4 s 9/5/97 10466 3 0 w2 e 9/2/97 1692 1 0 w2 e 9/4/97 6097 4 1 c3 e 9/5/97 3927 2 0 w2 s 9/2/97 3089 1 0 c3 s 9/3/97 2726 1 0 c3 s 9/4/97 2283 1 0 c3 s 9/5/97 7027 1 0 c3 R 9/2/97 177 1 0 w2 R 9/3/97 3365 1 0 w2 R 9/4/97 6291 2 0 w2 W 9/2/97 677 1 0 w2 W 9/3/97 2710 1 0 w2 W 9/5/97 1079 1 0 w2 script: #!perl open (IN, "sum.tab"); #open input file READ: while (<IN>) { chomp; if ($#db < 0) {$db[0] = $_; next READ;} #if there's no db array yet, just add the data and continue @_ = split/\t/; #@_ = split(on tabs) $_ (placed here for efficiency) $i = 0; while ($i <= $#db) { next READ if ($db[$i] eq $_); #if input and db array entries are equal, go to next input $slash = "/"; @dbc = split/\t/,$db[$i]; #split $db[$i] by tabs @dbcdate = split/$slash/,$dbc[1]; #split $dbc's date by tabs @_date = split/$slash/,$_[1]; #split $_'s date by tabs $older = ""; ##### if ($_date[2] < $dbcdate[2]) {$older = 1;} #sort for year elsif ($_date[2] == $dbcdate[2]) { if ($_date[0] < $dbcdate[0]) {$older = 1;} #sort for month elsif ($_date[0] == $dbc[0]) { if ($_date[1] < $dbcdate[1]) {$older = 1;} #sort for day elsif ($_date[1] == $dbcdate[1]) { #sort (alphabetically) using @db and @in, #remove duplicates, combine where needed. ##### if ($_[0] eq $dbc[0]) { #if they're equal in date and user, combine $dbc[2] += $_[2]; $dbc[3] += $_[3]; $dbc[4] += $_[4]; @newnas = split/ /,$_[5]; #nas means something- I don't remember what, though. =) for $x ( 0 .. $#newnas ) { if ($dbc[5] !~ m/$newnas[$x]/) { chomp( $dbc[5] .= " $newnas[$x]" ); } } #combine servers $db[$i] = "$dbc[0]\t$dbc[1]\t$dbc[2]\t$dbc[3]\t$dbc[4]\t$dbc[5]"; #set next READ; }else{ $sortable[0] = $db[0]; #create array for sorting $sortable[1] = $_[0]; #create array for sorting @sorted = sort (@sortable); #sort array if ($sorted[0] ne $sortable[0]) {$older = 1;} #check for placement and place accordingly } ##### } } } ##### if ($older == 1) { $q = $#db + 1; until ($q < $i) {$db[$q] = $db[$q - 1]; $q--;} #move each @db item up one $db[$i] = $in; #insert db item into $db[$i] next READ; #yeah, I could just copy the array, but this saves on memory. =) } $i++; } if ($i == $#db) {push (@db, $_);} #data is newer than all 'db' array elements. Place at end and continue. } close IN; #open (OUT, ">newlysorted.tab"); $v = 0; while ($v <= $#db) {print "$db[$v]\n"; $v++;} #would be print OUT #close (OUT); ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch