#!/usr/bin/perl

use CGI;
use strict;

use vars qw{
	$SourceVXML
	$DefaultStartIndex
	$DefaultCurrentMessage
};

$SourceVXML = 'exampleBBSBox.vxml';

$DefaultStartIndex = '0';

{
	my $contents;
	if (! open(INVXML, "<$SourceVXML"))
	{
		output("Error, could not load source VXML");
	}

	{
		undef $/;
		$contents = <INVXML>;
	}
	close (INVXML);

	my $query = new CGI;

	my $startidx = $query->param('msgstartindex') || $DefaultStartIndex;

	$contents =~ s/\[\[STARTIDX\]\]/$startidx/smg;

	output($contents);
}

sub output {
	my $tooutput = shift || "NOTHING";
	print "Content-type: text/xml\r\n\r\n";
	print $tooutput;
	exit 0;
}
