topcoder has asked for the wisdom of the Perl Monks concerning the following question:
First off, I'll be honest, I don't know anything about Perl other than it's a powerful language.
I'm trying to provide sample code to "Perl" programmers to use an API.
In C# this is the code..
In C# this is the code..
How would the above be converted to PERL? I seen a few different examples on the web (Might be out of date), but I don't have an easy way to test things. If some awesome monk can give me the basic syntax and then point me to an online Perl compiler that allows JSON REST Calls, I can probably take it from there.try { string apiKey = "Your Secret Key"; string emailToValidate = "example@example.com"; string responseString = ""; string apiURL = "https://api.zerobounce.net/v1/validate?apikey=" + +apiKey + "&email=" + HttpUtility.UrlEncode(emailToValidate); //Uncomment out to use the optional API with IP Lookup //string apiURL = "https://api.zerobounce.net/v1/validatewithip?api +key=" + apiKey + "&email=" + HttpUility.UrlEncode(emailToValidate); ++ "&ipaddress=" + HttpUtility.UrlEncode("99.123.12.122") HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiURL); request.Timeout = 150000; request.Method = "GET"; using (WebResponse response = request.GetResponse()) { response.GetResponseStream().ReadTimeout = 20000; using (StreamReader ostream = new StreamReader(response.GetRe +sponseStream())) { responseString = ostream.ReadToEnd(); } } } catch (exception ex) { Catch Exception - All errors will be shown here - if there are iss +ues with the API }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Help me convert this to Perl
by haukex (Archbishop) on Nov 27, 2017 at 17:11 UTC | |
by AnomalousMonk (Archbishop) on Nov 27, 2017 at 17:34 UTC | |
by 1nickt (Canon) on Nov 27, 2017 at 19:13 UTC | |
Re: Help me convert this to Perl
by 1nickt (Canon) on Nov 27, 2017 at 17:11 UTC | |
Re: Help me convert this to Perl
by FreeBeerReekingMonk (Deacon) on Nov 27, 2017 at 19:06 UTC | |
Re: Help me convert this to Perl
by Anonymous Monk on Nov 27, 2017 at 19:36 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Back to
Seekers of Perl Wisdom