troubleshooting Question

help converting asp with vbscript to perlscript

Avatar of itortu
itortuFlag for United States of America asked on
24 Comments3 Solutions444 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

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 3 Answers and 24 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 3 Answers and 24 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004