if ( $pop3 ) { # do something with the socket } else { print "error in socket: $!"; }