Mod perl and Programming for Standard Execution

From FreeSWITCH Wiki
Jump to: navigation, search

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:

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.