Greet Caller by Name in Perl
#!c:/Perl64/bin/perl.exe
print "Content-Type: text/plain\n\n";
#You have to add the directory route of perl.exe, and print the content type
use CGI qw(:cgi-lib :standard); # Use CGI modules that let read data passed
&ReadParse(%in); #Read in from HTTPPost parameters
%phoneBook =("+12345671", "John",
"+12345672", "Bill",
"+12345673", "Carl",
"1001", "Kevin",
"+12345675", "Jack");
my $CallerName = $phoneBook{$in{'Caller'}};
if (!$CallerName)
{ $CallerName = "Sir or Madam"; }
#Send response by print
print
'<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Speak>Hello '. $CallerName .'!</Speak>
</Response>'
Code example 1
- Greeting the caller by using a phonebook
IN MORE DETAILS
- When your application receives a call, you will get a Request with all of the call details.
- Fill an associative array with telephone numbers and names.
- In this associative array (phonebook) we are looking for the Caller parameter of the Request.
- After that, send back the response OzML to the caller.