Archived Forum Post

Index of archived forum posts


Perl syntax error w/ get_LastErrorText() ?

Oct 10 '12 at 11:27

When I run this Perl code, I get a runtime usage error on the line that calls get_LastErrorText.

      my $success = $mailman->SendEmail($email);
      unless($success) {
          print "Error: " . $mailman->get_LastSmtpStatus() . "\n";
          print "Error: " . $mailman->get_LastErrorText() . "\n";

I'm not reading something right in terms of getting LastErrorText?


The Chilkat classes / objects have a convention for string properties in the API's for C++, Perl, Java, Python, PHP, Ruby, etc. (but not for .NET, ActiveX, and Objective-C)

For the getter, there are two forms:

1) The form that returns a string. In this form, the property is represented as a function where the first letter is lowercase, and it return a string (or "const char *" in C++). For example:

    print $mailman->lastErrorText() . "\n";

2) The 2nd form is where the result is returned in a CkString object that is passed as the argument to the get_<prop_name> method. The CkString is an output-only arg, meaning that whatever contents it may have held will be discarded and replaced with the value of the string property. For example:

$mailman = new chilkat::CkMailMan();
$errTxt = new chilkat::CkString();
. . .
print $errTxt->getString() . "\n";

The error in the code snippet above is that you are trying to use the 2nd form to return a string. The correction is to replace "get_LastErrorText" with "lastErrorText".