I think you'll find that the actual perl code for that will be somewhat shorter than what I've written, but (since I assume this is homework) you should write the code. There are lots of places to read about hashes in Perl. Have you checked the Tutorials here at the Monastery?declare a hash (e.g. "my %lines." open the first input file while reading the first input one line at a time use the line as a hash key and assign "1" as the hash value close the file open output.file1 to hold "matching lines" open output.file2 to hold "distinct lines" open the second input file while reading the second input one line at a time if the current line exists as a hash key and the hash value is "1" print this line to the "matching lines" file increment the hash value otherwise print this line to the "distinct lines" file (maybe include the f +ile name) having read all input, now loop over all the keys of the hash if the hash value assigned to this key is still "1" print this hash key to the "distinct lines" file (maybe include t +he file name)
In reply to Re: comparing contents of the file
by graff
in thread comparing contents of the file
by Ms.Ranjan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |