pcap is a pretty standard library.
Check out
http://search.cpan.org/dist/Net-Pcap/Pcap.pm(view the samples!),
http://perlmonks.org/?node_id=170648, and
www.tcpdump.org.
If you are just beginning, use tcpdump to capture "everything" to a file, and start playing. Later, when you know what you're doing, move to processing live captures.