sub api_action { $api_action = $_[0]; use IO::Socket::SSL; $EOL = "\015\012"; $BLANK = $EOL x 2; $remote = IO::Socket::SSL->new( Proto => "tcp", PeerAddr => "api.xxxxx", PeerPort => "443", SSL_verify_mode => SSL_VERIFY_NONE, verify_hostname => 0, Timeout => 120, ); unless ($remote) { print "cannot connect to API\n"; return "ERROR"; } $remote->autoflush(1); print $remote "GET /API/?action=$api_action" . $BLANK; return <$remote>; close $remote; }