LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-05-2008, 05:11 PM   #1
Elguapo
Member
 
Registered: Mar 2005
Distribution: FC7
Posts: 42

Rep: Reputation: 15
Encoding ( ) in a url with perl


I am working on a re-write of an application and I have run into a bit of a snag when it comes to how I am formatting a url.

Currently I am using perl to facilate the data transfer between my servers and a RETS server. This is all done via a webservice. The uri syntax that I am required to use forces me to use () with in the uri.

IE
Code:
?SearchType=AGENT&Class=AGENT&Query=(UIDOFFICE=SCHW01+),(MLSSTATUS=A+)&Limit=NONE&Format=COMPACT-DECODED&QueryType=DMQL2
I have tried using URI::Escape, but this has gotten me no here. Anyone have an idea on how this can be done?
 
Old 05-06-2008, 01:12 PM   #2
WebmastTroy
LQ Newbie
 
Registered: May 2008
Posts: 1

Rep: Reputation: 0
I'm not trying to do your homework, but I understanding the challenges of specifically working with a RETS server, so:

Quote:
#!/usr/bin/perl

%params = (
'SearchType' => 'AGENT',
'Class' => 'AGENT',
'Query' => '(UIDOFFICE=SCHW01+),(MLSSTATUS=A+)',
'Limit' => 'NONE',
'Format' => 'COMPACT-DECODED',
'QueryType' => 'DMQL2'
);

$build_query_string = "";
foreach $key (keys %params) {
$params{$key} =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
$build_query_string .= "$key=$params{$key}&";
}

print $build_query_string;
Should get back something like:

Query=%28UIDOFFICE%3DSCHW01%2B%29%2C%28MLSSTATUS%3DA%2B%29&QueryType=DMQL2&Limit=NONE&Class=AGENT&Se archType=AGENT&Format=COMPACT%2DDECODED&
 
Old 05-06-2008, 02:43 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
The parentheses have special meaning in URIs which is why they’re not escaped by default with uri_escape(). You can, however, force this to happen by specifying a second parameter to uri_escape() manually. Also, you might try using Data::URIEncode or by using POST instead of GET.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URL parsing program in perl ludeKing Programming 3 09-30-2010 04:58 PM
Downloading a file from Url in perl bratieres Programming 2 03-01-2006 01:49 AM
URL-Encoding on the command line? MikeyCarter Linux - Software 2 09-27-2005 09:10 AM
url encoding doesn't work fine with PHP markus1982 Programming 0 08-30-2003 03:04 AM
URL Encoding kud0ze Programming 2 12-11-2001 01:38 PM


All times are GMT -5. The time now is 09:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration