Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help converting PERL code to ASP/VBscript

Status
Not open for further replies.

osfan82

Programmer
Feb 11, 2003
6
US
Hello,

I have some experience in PERL, but am completely new to ASP/VBscript. I have been picking up the basics over the past day or two, but need a little help with the code below. Essentially, the piece of code below accesses a html file using a GET method to pass along a user id. The page returned is an html page with a users information, which is then parsed through and each field is stored in seperate variables...

Code:
use LWP::UserAgent;
use HTTP::Request;

$userid = "abc";
$agent = new LWP::UserAgent;
$request = new HTTP::Request 'GET', "[URL unfurl="true"]http://www.someaddress.com/qdir?userid=$userid");[/URL]
$response = $agent->request($request);
$html = $response->content();

for (split '\n', $html)
{
   $uid = $1 if /UID\.+\s*(.+)/;
   $fullname = $1 if /Full Name\.+\s*(.+)/;
etc...


Any help in converting this over to VBScript would be greatly appreciated!


Thanks,
Troy
 
If all you are trying to do is access field values freom a form, all you need to do is
variable1 = Request.Form("FIELDNAME")

Much simpler in ASP that Perl glad I don't use it anymore.

If this is not what you wanted let me know.

 
Hey spaz,

Thanks for the help, but this doesn't really help in my situation. Guess I need to give a little more background...

Here on the intranet we have a directory of all of the users with info like building, room, telephone #, etc. We cannot access the database for this, but instead have to use qdir, which takes arguments like the userid in a GET post, so will return display an html page with something like this within it:

Full Name.......... My Name
Building........... Building 1
Room............... 1S234
etc.

Now the code I provided above creates an object to reference the http address of this page, and then stores all of the content of the html page into a single string in a scalar variable. I then read through each line of html code for the page looking for the info I need, for example if the line contains the word Full Name, I can use pattern matching/regular expressions to tag the value "My Name" and store that in a varaible.

Now I use this to validate a users id and pull all of their info, when a user comes to my pages to submit a trouble ticket. Now I've become part of another project which needs to do the same, but all of their code is in VBscript/ASP...

Hope this helped make it a little clearer. Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top