Example

To separate a phone number (e.g. 412-555-1973 x482) into area code, number, and extension.

In TopLeaf (custom content):

<perl-use module="ParsePhone"/>
. . .
<perl-call sub="parse_phone" arg="{PhoneNumber}"/>
<Emit string="{AreaCode}"/>
<Emit string="{Number}"/>
<Emit string="{Extn}"/>

In ParsePhone.pm:

sub parse_phone
{
  my $number = shift;
  $number =~ /^(\d\d\d)-(\d\d\d-\d\d\d\d)\s?(x\d+)?/;
  TopLeaf::set_var(AreaCode => $1);
  TopLeaf::set_var(Number => $2);
  TopLeaf::set_var(Extn => $3);
  TopLeaf::custom_marker(Dial, Number=>"$1$2");
}