Error Checking

To cleanly catch all errors while developing scripts, always specify output in XML format. This returns an error with any reply that does not return valid XML or any XML document with an error attribute.

The following example is from a PERL subroutine _cli that provides a shell for executing AVCLI commands. The code that checks for errors does a simple pattern match on $stdout.

my $error = 0
$error = 1 unless ($stdout =~ /xml version/);
$error = 1 if ($stdout =~ /\/);

If no error occurs, $stdout is cast into a PERL hash using the standard PERL XML::Simple Library. Otherwise, this error appears:

unless ($error) {
my $xs = XML::Simple->new();
$stdout_hash = $xs->XMLin($stdout,forceArray=>0);
return 0;
}
return 1;