Learning Perl on Win32 Systems

Learning Perl on Win32 SystemsSearch this book
Previous: 19.4 VariantsChapter 19
OLE Automation
Next: 19.6 Exercises
 

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 statement 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";


Previous: 19.4 VariantsLearning Perl on Win32 SystemsNext: 19.6 Exercises
19.4 VariantsBook Index19.6 Exercises