Link to home
Start Free TrialLog in
Avatar of itortu
itortuFlag for United States of America

asked on

help converting asp with vbscript to perlscript

I need to get some help changing an asp page with vbscript code to perlscript instead.
I tried to do it but there are parts I don't understand. Any help or guidance is very much appreciated.
the page is very basic but I lack the knowledge to do it on my own.

Thank you.

asp page:

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = true
Response.charset="utf-8"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
              <title>URL Id By Host</title>
              <link rel=stylesheet type="text/css" href="report.css" TITLE="wow" />
        </head>
<body>
<%
dim myParameterString, myQueryString, myhost

If Request.QueryString("host") <> "" Then
   myhost = Request.Querystring("host")
End If
%>
<form name="frmOne" id="frmOne" action="TMC_report.asp?host=<%=request.form("host")%>" method="get">
    <span class="host">Host:</span>
    <span class="indentHost"><input type="text" name="host" /></span>
    <input type="submit" value="Submit" name="btn_submit" />

</form>
<br />
<%
dim cn, rs, sql, host, i, strOrderBy, tmpOrderBy, zip

host = request.querystring("host")

strOrderBy = Request.QueryString("sortby")

Select Case strOrderBy
    Case "pv_a"
        tmpOrderBy = " ORDER BY sumaccess ASC"
    Case "pv_d"
        tmpOrderBy = " ORDER BY sumaccess DESC"
    Case "gi_a"
        tmpOrderBy = "ORDER BY groupId ASC"
    Case "gi_d"
        tmpOrderBy = "ORDER BY groupId DESC"
End Select

cn= "Driver={SQL Server};Server=xxx.xxx.x.xx;Database=databasename;Uid=sa;Pwd=password;"

Set rs = Server.CreateObject("ADODB.Recordset")

sql = "SELECT * FROM urlid_report_by_host where host like '" & myhost & "'"  & tmpOrderBy

rs.Open sql, cn, 3,3

Dim colorset, c, numcolors, rlabel

colorset = split("#E6E8FA,#EEE0E5",",")
numcolors = ubound(colorset)+1

%>
<table border="0" cellspacing="1" cellpadding="2" width="100%">
  <tr>
    <td class="head" valign="top">Host</td>
    <td class="head" valign="top">URL Id</td>
    <td class="head" valign="top">Group Id<br /><a href="TMC_report.asp?host=<%=host%>&amp;sortby=gi_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=gi_d&amp;host=<%=host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Label</td>
    <td class="head" valign="top">Access Views<br /><a href="TMC_report.asp?host=<%=host%>&amp;sortby=pv_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=pv_d&amp;host=<%=host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Latitude</td>
    <td class="head" valign="top">Longitude</td>
    <td class="head" valign="top">Zip Code</td>
  </tr>
<%
if not rs.eof and request("btn_submit") = "Submit" then
    while not rs.eof
        response.write "  <tr style=""background:" & colorset(c mod numcolors) & ";"">"
%>
    <td class="body" align="center"><p><%=Ucase(rs("Host"))%></p></td>
    <td class="body" align="center" width="244"><p><a href="http://xxx.xxxxxx.xxx/xx/xxxx.asp?id=<%=trim(rs("url_id"))%>" target="_blank">http://xxx.xxxxxx.xxx/xx/xxxx.asp?id=<%=trim(rs("URL_Id"))%></a></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("groupId"))%></p></td>
<%
      rlabel = rs("label")
    rlabel = replace(rlabel,"&","&amp;")
%>
    <td class="body"><p><%=rlabel%></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("sumaccess"))%></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("latitude"))%></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("longitude"))%></p></td>
<%
    if rs("Zip") <= "" OR ISNULL(rs("Zip")) then

        zip = "    <td class='nozip'><p>Not used</p></td>"
    else
        zip = "    <td class='body' align='center'><p>" & rs("Zip") &"</p></td>"

    end if
%>
        <%=zip%>
  </tr>
<%

        c = c + 1
        rs.MoveNext

    wend
    response.write "  <tr>" & vbcrlf & "    <td colspan='8' class='total'>Total number of records: " & rs.RecordCount & "</td>" & vbcrlf & "  </tr>"
elseif host <> "" then
%>
  <tr>
    <td class="message" colspan=7><p>There are no records for host <%=Ucase(host)%>. Please try again.</p></td>
  </tr>
<%
end if
    response.write vbcrlf & "</table>"
%>
</body>
</html>
<%
rs.close
set rs=nothing
%>
Avatar of Adam314
Adam314

What part aren't you sure about?
Why perlscript instead of just perl?
Avatar of itortu

ASKER

hi Adam314:

i am not sure about functions such as trim, replace, ucase and their equivalent in perlscript.

I started changing the code, but i can't go forward after this part:
my $rs = Server->CreateObject('ADODB.Recordset');

this is what i changed so far:

<%@ Language=PerlScript %>
<%
use strict;
use DBD::ODBC;

$Response->{Buffer} = 1;
$Response->{CharSet} = "utf-8";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
      <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <title>TMC URL Id By Host</title>
            <link rel=stylesheet type="text/css" href="report.css" TITLE="wow" />
        </head>
<body>

<%
my myParameterString;
my myQueryString;
my myhost;

if (Request->QueryString('host') ne '')
{
    $myhost = Request->Querystring('host');
}
%>

<form name="frmOne" id="frmOne" action="TMC_report.asp?host=<%=request->form('host')%>" method="get">
    <span class="host">Host:</span>
    <span class="indentHost"><input type="text" name="host" /></span>
    <input type="submit" value="Submit" name="btn_submit" />

</form>
<br />

<%
my sql;
my host;
my i;
my strOrderBy;
my tmpOrderBy;
my zip;

$host = request->querystring('host');

$strOrderBy = Request->QueryString('sortby');

if ($strorderBy = "pv_a")
{
    $tmpOrderBy = " ORDER BY sumaccess ASC";
}
elsif ($strorderBy = "pv_d")
{
    $tmpOrderBy = " ORDER BY sumaccess DESC";
}
elsif ($strOrderBy = "gi_a")
{  
    $tmpOrderBy = "ORDER BY groupId ASC";
}
elsif (strOrderBy = "gi_d")
{
    $tmpOrderBy = "ORDER BY groupId DESC";
}

my $cn= 'Driver={SQL Server};Server=xxx.xxx.x.xx;Database=TargetedMicrocast;Uid=sa;Pwd=myweather;';
Avatar of itortu

ASKER

the remaining code i don't know how to proceed.  and to be honets i am not sure if what i have changed so far is correclty done.

my $sql = 'SELECT * FROM dbo.tmc_urlid_report_by_host where host like '" & myhost & "'"  & tmpOrderBy



rs.Open sql, cn, 3,3

Dim colorset, c, numcolors, rlabel

colorset = split("#E6E8FA,#EEE0E5",",")
numcolors = ubound(colorset)+1

%>
<table border="0" cellspacing="1" cellpadding="2" width="100%">
  <tr>
    <td class="head" valign="top">Host</td>
    <td class="head" valign="top">URL Id</td>
    <td class="head" valign="top">Group Id<br /><a href="TMC_report.asp?host=<%=host%>&amp;sortby=gi_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=gi_d&amp;host=<%=host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Label</td>
    <td class="head" valign="top">Access Views<br /><a href="TMC_report.asp?host=<%=host%>&amp;sortby=pv_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=pv_d&amp;host=<%=host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Latitude</td>
    <td class="head" valign="top">Longitude</td>
    <td class="head" valign="top">Zip Code</td>
  </tr>
<%
if not rs.eof and request("btn_submit") = "Submit" then
    while not rs.eof
        response.write "  <tr style=""background:" & colorset(c mod numcolors) & ";"">"
%>
    <td class="body" align="center"><p><%=Ucase(rs("Host"))%></p></td>
    <td class="body" align="center" width="244"><p><a href="http://pmc.myweather.net/fc/mc.asp?id=<%=trim(rs("url_id"))%>" target="_blank">http://pmc.myweather.net/fc/mc.asp?id=<%=trim(rs("URL_Id"))%></a></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("groupId"))%></p></td>
<%
      rlabel = rs("label")
        rlabel = replace(rlabel,"&","&amp;")
%>
    <td class="body"><p><%=rlabel%></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("sumaccess"))%></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("latitude"))%></p></td>
    <td class="body" width="75" align="center"><p><%=trim(rs("longitude"))%></p></td>
<%
    if rs("Zip") <= "" OR ISNULL(rs("Zip")) then

        zip = "    <td class='nozip'><p>Not used</p></td>"
    else
        zip = "    <td class='body' align='center'><p>" & rs("Zip") &"</p></td>"

    end if
%>
        <%=zip%>
  </tr>
<%

        c = c + 1
        rs.MoveNext

    wend
    response.write "  <tr>" & vbcrlf & "    <td colspan='8' class='total'>Total number of records: " & rs.RecordCount & "</td>" & vbcrlf & "  </tr>"
elseif host <> "" then
%>
  <tr>
    <td class="message" colspan=7><p>There are no records for host <%=Ucase(host)%>. Please try again.</p></td>
  </tr>
<%
end if
    response.write vbcrlf & "</table>"
%>
</body>
</html>
<%
rs.close
set rs=nothing
%>

For trim:
   $var =~ s/^\s+//;    #Remove leading whitespace
   $var =~ s/\s+$//;    #Remove trailing whitespace

For replace:
   $var =~ tr/abc/def/;    #replace abc with def

For ucase:
  $var = uc($var);

For my $rs = Server->CreateObject('ADODB.Recordset');
this is creating an ADODB.Recordset object.  The ADODB is an interface to a database.  The more common database interface used in perl is DBI, but changing to the DBI module would require more work.  To use the same ADODB interface:
my $rs = Win32::OLE->new("ADODB.Recordset");

If you aren't at all familiar with perl, you might want to do a little reading first.  Try http://perldoc.perl.org, read the overview sections.
Avatar of itortu

ASKER

this is far more complicated that was i thought.

do i keep or remove this part: rs.Open sql, cn, 3,3
what do i use for this part? :
colorset = split("#E6E8FA,#EEE0E5",",")
numcolors = ubound(colorset)+1

if this is much to ask, i understand just let me know and i close the question, thank you adam314.
SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<%@ Language=PerlScript %>
<%
use Win32::OLE::Variant;

sub trim
{
      my $val = shift;
      $val =~ s/^\s+|\s+$//;
      return $val;
}

sub Request
{
      # don't know if perlscript has a builtin way
      # to mirror vbscript's request object traversal so...

      my $item = shift;
      for my $collection ($Request->QueryString, $Request->Form, $Request->Cookies, $Request->ClientCertificates, $Request->ServerVariables ) {
            for (in $collection) {
                  return $collection->{$item}->Item if ($_ eq $item);
            }
      }
      return undef;
}

sub Contains
{
      my ($collection, $item) = @_;
      for (in $collection) { return 1 if ($_ eq $item); }
      return 0;
}

sub IsNull
{
      my $variant = shift;
      return ($variant->Type() == VT_NULL);
}


$Response->{Buffer} = 1;
$Response->{CharSet} = "utf-8";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
              <title>URL Id By Host</title>
              <link rel=stylesheet type="text/css" href="report.css" TITLE="wow" />
        </head>
<body>
<%

my ($myParameterString, $myQueryString, $myhost);

$myhost = $Request->QueryString("host")->Item if Contains($Request->QueryString,"host");

%>
<form name="frmOne" id="frmOne" action="TMC_report.asp?host=<%=$Request->Form("host")->Item %>" method="get">
    <span class="host">Host:</span>
    <span class="indentHost"><input type="text" name="host" /></span>
    <input type="submit" value="Submit" name="btn_submit" />

</form>
<br />
<%
my ($cn, $rs, $sql, $host, $i, $strOrderBy, $tmpOrderBy, $zip);

$host = $Request->QueryString("host")->Item;

$strOrderBy = $Request->QueryString("sortby")->Item;

$tmpOrderBy = " ORDER BY sumaccess ASC" if $strOrderBy eq "pv_a";
$tmpOrderBy = " ORDER BY sumaccess DESC" if $strOrderBy eq "pv_d"
$tmpOrderBy = " ORDER BY groupId ASC" if $strOrderBy eq "gi_a";
$tmpOrderBy = " ORDER BY groupId DESC" if $strOrderBy eq "gi_d";


$cn = "Driver={SQL Server};Server=xxx.xxx.x.xx;Database=databasename;Uid=sa;Pwd=password;";

$rs = $Server->CreateObject("ADODB.Recordset")

$sql = "SELECT * FROM urlid_report_by_host where host like '$myhost' $tmpOrderBy";


$rs->Open($sql, $cn, 3, 3);


my (@colorset, $c, $numcolors, $rlabel)


@colorset = ("#E6E8FA", "#EEE0E5");

$numcolors = $#colorset + 1;

%>
<table border="0" cellspacing="1" cellpadding="2" width="100%">
  <tr>
    <td class="head" valign="top">Host</td>
    <td class="head" valign="top">URL Id</td>
    <td class="head" valign="top">Group Id<br /><a href="TMC_report.asp?host=<%=$host%>&amp;sortby=gi_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=gi_d&amp;host=<%=$host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Label</td>
    <td class="head" valign="top">Access Views<br /><a href="TMC_report.asp?host=<%=$host%>&amp;sortby=pv_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=pv_d&amp;host=<%=$host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Latitude</td>
    <td class="head" valign="top">Longitude</td>
    <td class="head" valign="top">Zip Code</td>
  </tr>
<%
if (!$rs->{EOF} && (Request('btn_submit') eq "Submit")) {

   while (!$rs->{EOF})  {

        $colorindex = $c % $numcolors;

%>

    <tr style="background:$colorset[$colorindex];">

    <td class="body" align="center"><p><%=uc($rs->Fields("Host")->{Value}))%></p></td>
    <td class="body" align="center" width="244"><p><a href="http://xxx.xxxxxx.xxx/xx/xxxx.asp?id=<%=trim($rs->Fields("url_id")->{Value})%>" target="_blank">http://xxx.xxxxxx.xxx/xx/xxxx.asp?id=<%=trim($rs->Fields("URL_Id")->{Value})%></a></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("groupId")->{Value})%></p></td>
<%
    $rlabel = $rs->Fields("label")->{Value}
    $rlabel =~ s/&/&amp;/g;

%>
    <td class="body"><p><%=$rlabel%></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("sumaccess")->{Value})%></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("latitude")->{Value})%></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("longitude")->{Value})%></p></td>
<%
    if (  !($rs->Fields("Zip")->{Value} gt "") || IsNull($rs->Fields("Zip")->{Value}) ) {
      $zip = "    <td class='nozip'><p>Not used</p></td>";
    }
    else {
        $zip = "    <td class='body' align='center'><p>".$rs->Fields("Zip")->{Value}."</p></td>"
    }
%>
        <%=$zip%>
  </tr>
<%

        $c++;
        $rs->MoveNext();
   }
%>

  <tr>

    <td colspan='8' class='total'>Total number of records: <%= $rs->{RecordCount} %></td>
  </tr>

elsif $host eq "" {
%>
  <tr>
    <td class="message" colspan=7><p>There are no records for host <%=uc($host)%>. Please try again.</p></td>
  </tr>
<%
}
%>
</table>
</body>
</html>

<%

$rs->Close();
undef $rs;

%>
Avatar of itortu

ASKER

hi clockwatcher and thank you for changing the whole script for me.

i am trying to run the page, but i get some errors that may be if you have time, can help me debug.

PerlScript Error (0x80004005)
syntax error at (eval 2) line 34, near ") my " 
syntax error at (eval 2) line 37, near ") Response"
syntax error at (eval 2) line 44, near ""pv_d" $tmpOrderBy " 
syntax error at (eval 2) line 48, near ") $sql " 
syntax error at (eval 2) line 51, near ") @colorset " syntax error
/targetedmc/perlscript_TMC_report.asp, line 102

line 102 :

<td class="head" valign="top">Group Id<br /><a href="perlscript_TMC_report.asp?host=<%=$host%>&amp;sortby=gi_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="perlscript_TMC_report.asp?sortby=gi_d&amp;host=<%=$host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>

Once again, thank you for your help.
Avatar of itortu

ASKER

i'm not sure if this has something to do with use Win32::OLE::Variant;

i check the Perl lib folder and I found the module Win32.pm

do I have to install something else?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itortu

ASKER

most of the syntax errors were corrected with your new code, there are two that still remain.

syntax error at (eval 2) line 34, near ") my " 
syntax error at (eval 2) line 37, near ") Response"
syntax error
/targetedmc/perlscript_TMC_report.asp, line 102

It runs on two of my machines without error and nowhere do I have either a ") my" or a ") Response".

The only place I even reference Response is:

$Response->{Buffer} = 1;
$Response->{CharSet} = "utf-8";

And there's no reference to a my anywhere near three lines above that.

Can you copy and paste the code you're using?
Avatar of itortu

ASKER

<%@ Language=PerlScript %>
<%
use Win32::OLE::Variant;

sub trim
{
      my $val = shift;
      $val =~ s/^\s+|\s+$//;
      return $val;
}

sub Request
{
      # don't know if perlscript has a builtin way
      # to mirror vbscript's request object traversal so...

      my $item = shift;
      for my $collection ($Request->QueryString, $Request->Form, $Request->Cookies, $Request->ClientCertificates, $Request->ServerVariables ) {
            for (in $collection) {
                  return $collection->{$item}->Item if ($_ eq $item);
            }
      }
      return undef;
}

sub Contains
{
      my ($collection, $item) = @_;
      for (in $collection) { return 1 if ($_ eq $item); }
      return 0;
}

sub IsNull
{
      my $variant = shift;
      return ($variant->Type() == VT_NULL);
}


$Response->{Buffer} = 1;
$Response->{CharSet} = "utf-8";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
              <title>URL Id By Host</title>
              <link rel=stylesheet type="text/css" href="report.css" TITLE="wow" />
        </head>
<body>
<%

my ($myParameterString, $myQueryString, $myhost);

$myhost = $Request->QueryString("host")->Item if Contains($Request->QueryString,"host");

%>
<form name="frmOne" id="frmOne" action="TMC_report.asp?host=<%=$Request->Form("host")->Item %>" method="get">
    <span class="host">Host:</span>
    <span class="indentHost"><input type="text" name="host" /></span>
    <input type="submit" value="Submit" name="btn_submit" />

</form>
<br />
<%
my ($cn, $rs, $sql, $host, $i, $strOrderBy, $tmpOrderBy, $zip);

$host = $Request->QueryString("host")->Item;

$strOrderBy = $Request->QueryString("sortby")->Item;

$tmpOrderBy = " ORDER BY sumaccess ASC" if $strOrderBy eq "pv_a";
$tmpOrderBy = " ORDER BY sumaccess DESC" if $strOrderBy eq "pv_d";
$tmpOrderBy = " ORDER BY groupId ASC" if $strOrderBy eq "gi_a";
$tmpOrderBy = " ORDER BY groupId DESC" if $strOrderBy eq "gi_d";


$cn = "Driver={SQL Server};Server=xxx.xxx.x.xx;Database=TargetedMicrocast;Uid=sa;Pwd=myweather;";

$rs = $Server->CreateObject("ADODB.Recordset");

$sql = "SELECT * FROM urlid_report_by_host where host like '$myhost' $tmpOrderBy";


$rs->Open($sql, $cn, 3, 3);


my (@colorset, $c, $numcolors, $rlabel);


@colorset = ("#E6E8FA", "#EEE0E5");

$numcolors = $#colorset + 1;

%>
<table border="0" cellspacing="1" cellpadding="2" width="100%">
  <tr>
    <td class="head" valign="top">Host</td>
    <td class="head" valign="top">URL Id</td>
    <td class="head" valign="top">Group Id<br /><a href="TMC_report.asp?host=<%=$host%>&amp;sortby=gi_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=gi_d&amp;host=<%=$host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Label</td>
    <td class="head" valign="top">Access Views<br /><a href="TMC_report.asp?host=<%=$host%>&amp;sortby=pv_a&amp;btn_submit=Submit"><span class="link">ASC</span></a>|<a href="TMC_report.asp?sortby=pv_d&amp;host=<%=$host%>&amp;btn_submit=Submit"><span class="link">DESC</span></a></td>
    <td class="head" valign="top">Latitude</td>
    <td class="head" valign="top">Longitude</td>
    <td class="head" valign="top">Zip Code</td>
  </tr>
<%
if (!$rs->{EOF} && (Request('btn_submit') eq "Submit")) {

   while (!$rs->{EOF})  {

        $colorindex = $c % $numcolors;

%>

    <tr style="background:$colorset[$colorindex];">

    <td class="body" align="center"><p><%=uc($rs->Fields("Host")->{Value})%></p></td>
    <td class="body" align="center" width="244"><p><a href="http://xxx.xxxxxx.xxx/xx/xxxx.asp?id=<%=trim($rs->Fields("url_id")->{Value})%>" target="_blank">http://xxx.xxxxxx.xxx/xx/xxxx.asp?id=<%=trim($rs->Fields("URL_Id")->{Value})%></a></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("groupId")->{Value})%></p></td>
<%
    $rlabel = $rs->Fields("label")->{Value};
    $rlabel =~ s/&/&amp;/g;

%>
    <td class="body"><p><%=$rlabel%></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("sumaccess")->{Value})%></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("latitude")->{Value})%></p></td>
    <td class="body" width="75" align="center"><p><%=trim($rs->Fields("longitude")->{Value})%></p></td>
<%
    if (  !($rs->Fields("Zip")->{Value} gt "") || IsNull($rs->Fields("Zip")->{Value}) ) {
      $zip = "    <td class='nozip'><p>Not used</p></td>";
    }
    else {
        $zip = "    <td class='body' align='center'><p>".$rs->Fields("Zip")->{Value}."</p></td>"
    }
%>
        <%=$zip%>
  </tr>
<%

        $c++;
        $rs->MoveNext();
   }
%>

  <tr>

    <td colspan='8' class='total'>Total number of records: <%= $rs->{RecordCount} %></td>
  </tr>

elsif $host eq "" {
%>
  <tr>
    <td class="message" colspan=7><p>There are no records for host <%=uc($host)%>. Please try again.</p></td>
  </tr>
<%
}
%>
</table>
</body>
</html>

<%

$rs->Close();
undef $rs;

%>
Weird.  Runs fine on my system.  And I don't see any references to a bare "Response" anywhere.  I don't think I'm going to be able to help, because I don't see how the errors you're getting are coming from the code that's up there.
To help solve:  Comment out some lines around lines 34-37, and see if it runs.  If so, you know one of those commented lines is causing the problem.  If you still get an error: comment more lines and try again.  Keep going until you determine which lines are causing the problem.  

Is there a reason you are using perlscript instead of perl?
I think it'd be easier to get help if you were using perl.
Avatar of itortu

ASKER

hi Adam314,
i will commnet out the lines as you said. also, if this is done using perl can it still be run from this page?
if you don't mind showing me how this is done, i am open to try it.

thank you.

itortu.
Avatar of itortu

ASKER

i commented out this sub

#sub IsNull
#{
#      my $variant = shift;
#      return ($variant->Type() == VT_NULL);
#}

because this are lines 33-37 but when i run the page, it keeps sending the same message

PerlScript Error (0x80004005)
syntax error at (eval 2) line 34, near ") my " 
syntax error at (eval 2) line 37, near ") Response"
syntax error
/perlscript_TMC_report.asp, line 102

am i commenting out the lines correctly?
I'm not sure.  I know that would be correct in perl, but am not familiar with perlscript.
Try commenting out the rest of the file, from line 33 - end.  If it works, then uncomment a few lines at a time until it stop working - that should help narrow it down.
Avatar of itortu

ASKER

i think it this line:

use Win32::OLE::Variant;

the Variant part, how do I know if I have this module installed?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itortu

ASKER

i am doing the conversion for curiosity, and i appreciate all your help. i apologize if i have bugged you with this for a simple reason. i would like to learn more perl but it is hard to find some time to do it.

thank you.
I've had strange/difficult to find errors before.  This is what I do: comment out the entire program.  Make sure it runs (of course, nothing happens).  This lets you know the problem is not with your configuration or settings or anything like that.  Uncomment a few lines, and re-run (of course, if you uncomment the start of a sub, you need to uncomment the closing curly brace).  Repeat this (uncomment a few lines, then re-run) until you find the error.

If you want to learn perl, and are doing this for curiosity, I would start by reading a perl book.  Or at least some tutorials on the web.  Once you understand the basics, then you could convert the ASP to perl.  

I know everyone likes to learn differently, but I don't think you'll be able to get much from seeing similiar (to the VBScript) in perl until you have the basic down.

I don't mind helping (and I'm guessing other experts agree), even if what you want to do is just learn and play around.  I just think you'll get more using other methods.
You're certainly not bugging any of us.   I was just wondering why you decided to go with PerlScript.  

I wish I could be of more help, but I have no idea why you're getting the errors that you're getting since they reference code that doesn't even exist in the page that you're trying to execute.  I'd guess that you had a cached version of the page or something, but since the modified code did cut down on the number of errors it doesn't seem likely to be that.

Commenting lines until you find the problem as Adam suggested would be a good approach, but it's liable to break something else-- not sure that that wouldn't be an improvement-- at least it would be a change.

The "Response" error really makes no sense at all.  Since nothing references Response.  There are only two references to the word Response and both of those are $Response-- not just Response.  Anyway... very odd errors.

Converting the page to a perl (not perlscript) version, would allow you to get more help when you run into problems.  There just aren't enough people around that use PerlScript.
Avatar of itortu

ASKER

no problem guysm thank yo uvery much for helping me. i will buy a perl book to learn its syntax the right way. i won't have internet for the rest of the day, and i don't want to close the question in a rush. by thirsday i will have internet access again and i  will go thorugh the comments on the question, to split the points fairly between the two o f you guys, since you both have offered me valuable recommendations.

thank you again.

itortu.