in reply to Trying to get the complete opposite end results
In a one-liner of the Bash shell that is two sort steps followed by one diff (or if you prefer, uniq).
You don’t need to “write a program” at all.
If you have a slew of similar operations to do, especially if you’re not always sure what you would like to do next, consider putting the data into an SQLite database (file... no server is involved) whereby you can now use LEFT OUTER JOIN in SQL to obtain non-matching rows, and nested queries to perform more complex operations. Once again doing so from the command-line of existing tools.
Now, of course I’m not saying that it cannot also be done in Perl ... the language is called a Swiss Army® Knife for plenty of great reasons.