Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-18 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found