So can you ping imap.gmail.com? Have you read Gmail IMAP access, apparently it is a working example.
In reply to Re^3: GMail IMAP SSL and Perl by marto in thread GMail IMAP SSL and Perl by texasag90