A search on
Sourceforge.net comes up with several programs that use perl to interface with the icq protocol. One such thing you'll probably want to check out is
Net::ICQ it's "a set of Perl modules that allow you to access the ICQ Instant Messaging. These modules provide you access to creating/receiving messages, writing clients, etc."
Best of luck :)