RatArsed has asked for the wisdom of the Perl Monks concerning the following question:

I've got the fun task of converting some ASP to Perl, pretty trivial except for the case where I get something like this (JScript):

var rsFollow = Server.CreateObject('ADODB.Recordset'); /* snip */ while (!rsFollow.EOF) { Response.Write(' <tr>\n'); Response.Write(' <td>' + rsFollow("Book Title") + '</td>\n' +); rsFollow.MoveNext(); }

Now, most of this can be ported relatively easily, so that you get something like:

my $rsFollow = Win32::OLE->new('ADODB.Recordset'); # snip while( !$rsFollow->{EOF} ) { print( " <tr>\n" ); print( " <td> $rsFollow->{'Book Title'} + </td>\n"); print( " </tr>\n" ); $rsFollow->MoveNext(); }
This however doesn't work, spewing out a bunch of errors ("Win32::OLE=HASH(0x1a71c20)" etc)

But it seems Perl doesn't want to iterate through the collections until it matches?

PS: I'm using strict and warnings, and this isn't going to stay as spewing out HTML...

--
RatArsed

Replies are listed 'Best First'.
Re: Using COM in Perl
by t0mas (Priest) on Aug 14, 2001 at 14:56 UTC
    Isn't it the _Value_ of $rsFollow->{'Book Title'} you want to print? Like $rsFollow->{'Book Title'}->{Value}.

    $rsFollow->{'Book Title'} has _many_ other attributes, like Name, Type and Status. I think VB assumes that it is the Value you want to print, while Perl don't.

    You can print the all the attributes of it with:
    foreach (keys %{$rsFollow->{'Book Title'}}) { print $_."\n"; }


    /brother t0mas
      And there was me thinking it was bitching about not knowing about the default collection or something(!)

      Many thanks...

      --
      RatArsed