troubleshooting Question

help converting asp with vbscript to perlscript

Avatar of itortu
itortuFlag for United States of America asked on
24 Comments1 Solution444 ViewsLast Modified:
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
            <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" />
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" />

<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};;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%">
    <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>
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="<%=trim(rs("url_id"))%>" target="_blank"><%=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>"
        zip = "    <td class='body' align='center'><p>" & rs("Zip") &"</p></td>"

    end if

        c = c + 1

    response.write "  <tr>" & vbcrlf & "    <td colspan='8' class='total'>Total number of records: " & rs.RecordCount & "</td>" & vbcrlf & "  </tr>"
elseif host <> "" then
    <td class="message" colspan=7><p>There are no records for host <%=Ucase(host)%>. Please try again.</p></td>
end if
    response.write vbcrlf & "</table>"
set rs=nothing
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 24 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 24 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros