Mod perl and Programming for Standard Execution
There are two ways of using the mod_perl module, this is to talk about using it to actually execute a dialplan (or for running from the console with consolerun). The items mentioned in the primary mod_perl entry apply here and it should be read first.
To start your Perl scripts should begin with:
#!/usr/bin/perl use strict; our $session;
The $session variable represents the user's session object.
mod_perl will automatically import the "freeswitch" perl module, but nothing is imported into the global namespace. This means if you want to access a non-instance function from the class, say consoleLog it is freeswitch::consoleLog.
Unfortunately there is very little documentation of the mod_perl module and the actual code itself is not overly obvious (some of it is auto-generated from swig). For the full function list see Mod perl functions and classes
Your script should always end with a line of '1;'
Or if you are returning out of the script make sure you use 'return 1' not just 'return'
There is virtually nothing you can't do with mod_perl that you can in an XML dialplan and it certainly gives you additional functionality. See the examples for some ways you can use it.
- Perl Console IVR Example - Simple perl console IVR to allow you to dial into a shell like interface.
- Perl DialPlan Executor Example - Carrying how a dialplan using perl instead of the normal dialplan script
- Perl LDAP Lookup example - Grand central like app
- Perl Live Session Intercept IVR Example - an IVR interface to all current sessions and allows them to be taken over
- Perl Text-to-Speech Example
- Perl Play WAV File Example
- Example Dial Plan Application to Launch a Perl Script