I am writing a program where I want to be able to locate information regarding a person in one file, if they appear in another.
For instance: I have a file that just has student IDs (for students that are new) It has a long list of Student IDs like this: 100955 104024 564765 123456 765437 123321 323999 444555 Then there is another file that has information such as this: 100955 BLow-Gomez, Joseph M MEX.AMER. QHUTC012 101121 NOBODY, GARY E. M CAUC COCO0502 101985 sOMEBODY, RICHARD M CAUC COCO0404 102989 GUY, JON G. M BLACK COCO0505 103257 DUDE, MICHAEL D. M CAUC TENN3306 104024 CHICK, JENNY A. M BLACK QHUTJ005 104272 GIRL, JOSIE R. M MEX.AMER. TENN3201 104586 BOY, TERRELL L. M BLACK QHUTG013 104802 SOMEFELLA, JAMES D. M BLACK QHUTA001 105011 PERSON, JAMES J. M CAUC COCO1909 106455 HUMAN, STEPHEN J. M CAUC YUMAD012 106461 HOMOSAPIEN, RODNEY M BLACK QHUTB014 106953 ERECTUS, JAVIER M MEX.NAT. COCO0701 107461 THIRTYTWOTEETH, TIMOTHY M CAUC TENS0904 108594 TACOBELL, ARNOLD G. M MEX.AMER. TENN2303 (all tab delimited) For each id in the first file, I want to match it in the second file and then print all the info contained in the second file into a third file that contains only the people that were in both. This is essentially what I have so far… This only gets me up to a certain point. It doesn’t do the comparison. $ifile = "roster.txt"; $ofile = "output.txt"; open(IFILE, "$ifile"); open(OFILE, "+>$ofile"); #store the file in an array. my @guys; while ($line = <IFILE>) { if ($line =~ /^\d\d\d\d\d+/) { $things = substr $line,0,51; push @guys,$things; } } foreach $line (@guys) { if ($line =~ /^0/) { ($trash,$rest) = split(/^0/,$line); print OFILE "$rest\n"; }else{ print OFILE "$line\n"; } } close IFILE; close OFILE; $tfile = "testing.txt"; open(IFILE, "$ofile"); open(TFILE, "+>$tfile"); while (<IFILE>) { chomp; my ($adc, $record) = split(/\t+/,$_); push @{$table{$adc}}, $record; } foreach $adc (sort keys %table) { print TFILE "$adc "; my @records = @{$table{$adc}}; print join ', ', sort @records; print TFILE "\n"; } close IFILE; close TFILE; $cfile = "changes.txt"; $output = "output.txt"; open(TFILE, "$tfile"); open(TFILE, "$cfile"); open(OFILE, "+>$output"); I am open to a complete rewrite of course, since the above code only gets me the file to compare to (the one with the info in it) it does not do the comparison (obviously) Please help -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/