[Chapter 19] 19.5 Tips and Techniques
Author: Randal L. Schwartz, Erik Olson & Tom Christiansen
Date: 1999-07-02T01:37:20Z

#

| Chapter 19 OLE Automation |

## 19.5 Tips and Techniques

Here are a couple of tips for using OLE automation from Perl.

### 19.5.1 Translating Samples from Visual Basic

Finding documentation and examples that show you how to use an automation server from Perl can be difficult. You'll more likely find examples for Visual Basic. Converting automation examples from Visual Basic to Perl is quite easy.

Visual Basic also uses a `CreateObject` call to create automation objects. Visual Basic uses a `set` `s`tatement to assign an object, whereas Perl just needs a normal assignment. Visual Basic references properties and methods using the dot operator, while Perl uses the pointer arrow for methods, and the pointer arrow and a hash for properties. Here's a brief snippet from Visual Basic:

    set Message = ActiveSession.Outbox.Messages.Add
    Message.Subject = "Subject"
    Message.Text = "Text"

And here's the translation into Perl:

    $Message = $ActiveSession->Outbox->Messages->Add();
    $Message->{Subject} = "Subject";
    $Message->{Text} = "Text";

19.4 Variants |  | 19.6 Exercises