in reply to Using unix commands in perl?

On your system you will never have duplicates if you are including the source IP and port, the destination IP and port because those four components must be unique on your system.

As an example;

If you have a service listening on a particular port and multiple incoming connections are made from the same external host, the destination IP and port will be the same (your server) and the source IP address will be the same but the source port will be different for each connection.