That understanding will help you, but there will be other differences. For instance, this.that = 2 in VB would be $this->{that} = 2 in Perl. But something like a method call would be this->DoSomething.

Using Win32::OLE isn't as straightforward as you might want it to be. The biggest things to look out for is that when you're setting properties, you're going to be using a hash, and there are other times when you're going to be using lists. For example..

This is some DB code that uses ADO..

#!/usr/bin/perl -w use strict; use Win32::OLE; my $strCon = "Provider=SQLOLEDB; Data Source=XXXXX; Initial Catalog=SM +S; " . "User ID=XXXXX; Password=XXXXX"; my $strSql = "SELECT System_DATA.Name0, datediff(dd, LastUpdateDate, g +etdate())" . " 'age' FROM SoftwareInventoryStatus INNER JOIN System_DATA on " . "System_Data.MachineID = SoftwareInventoryStatus.ClientID WHERE + " . "(datediff(dd, LastUpdateDate, getdate()) > 30)" ; my $objCon = new Win32::OLE("ADODB.Connection"); my $objRecordset = new Win32::OLE("ADODB.Recordset"); $objCon->{'ConnectionString'} = $strCon; $objCon->Open; $objRecordset->Open($strSql, $objCon); while (not $objRecordset->{'EOF'}) { print $objRecordset->{'Name0'}{'Value'}, "\t"; print $objRecordset->{'age'}{'Value'}, "\n"; $objRecordset->MoveNext; } $objRecordset->Close; $objCon->Close;
and someting similar in VB (sorry, this below is from some ASP a customer asked me to put together. Above is something I use. They don't perform the same task, but you should be able to see what mirrors what.
Option Explicit Dim objConnection, objRecordset, strSQL, Name Set objConnection = Server.CreateObject("ADODB.Connection") objConnection.ConnectionString = "Provider=SQLOLEDB; Data Source=XXXX +; Initial Catalog=SMS; User ID=XXXX; Password=XXXX" objConnection.Open Set objRecordset = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT Name0, MachineID FROM System_DATA WHERE MachineID >= + 0 ORDER BY Name0" objRecordset.Open strSQL, objConnection
and what was a little confusing to figure out is that in VB, You can refrence the "Name0" field as objRecordset("Name0") but in Perl it's $objRecordset->{'Name0'}{'Value'} I personally prefer Perl, but with things like Win32::OLE it's a lot of poke and hope to figure out just how you have to access properties and methods.

In reply to Re: Re: Dots and cargo-cult programming by rchiav
in thread Dots and cargo-cult programming by bikeNomad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.