my %session_hash; my %departments; # for each of the 6 session files, # open and read line-by-line # parse out user_id, session_id, dept_code $session_hash{$session_id} = $dept_code; $departments{$dept_code}++; # # for each apache log # open and read line-by-line # parse out session_id # append the line to the file associated with $session_hash{$session_id}