Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Re: Dots and cargo-cult programming

by rchiav (Deacon)
on Jul 16, 2001 at 03:05 UTC ( #96914=note: print w/replies, xml ) Need Help??

in reply to Re: Dots and cargo-cult programming
in thread Dots and cargo-cult programming

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://96914]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2023-09-25 22:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found