CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Splitting a URL into parts

 



remi
Novice

Oct 9, 2002, 6:46 AM

Post #1 of 3 (357 views)
Splitting a URL into parts Can't Post

Good day to all,
I have a set of URLs that I have to split into bits and use each splited section as a new Url. The URL looks like this:

130.73.63.88 - - [17/Sep/2002:13:51:57 +0200] "GET /V/SU3R23N8D8VN1416RL24TG4NU8AD6GP21IAGVXTSEHJC74JT7Q-01411/find-1? FIND_CODE_1=WTI&FIND_REQUEST_1=JAVA&FIND_OP_1=AND&FIND_CODE_2=WTI&FIND_REQUEST_2=&BASE=BBF_BERLIN&BASE=FHW_BERLIN&BASE=IAI_BERLIN&BASE=HDK01&BASE=VOEB&BASE=FH_EBERSWALDE&BASE=GFZ_POTSDAM&BASE=UBP01&BASE=TFH_WILDAU& x=25&y=2 HTTP/1.1" 200 276


This is a common Log file. After the /find-1?, the URL has to be divided after every "&" sign. The splitted URL will look like this:

FIND_CODE_1=WTI&
FIND_REQUEST_1=JAVA&
FIND_OP_1=AND&
FIND_CODE_2=WTI&
FIND_REQUEST_2=Database&
BASE=SBB&
BASE=FTW01&
BASE=HUB01&
BASE=TUB01&
BASE=FES01&
BASE=BTU01&
BASE=FH_POTSDAM&
BASE=SLB_POTSDAM&
BASE=COLL_POLONICUM&
x=21&y=4 HTTP/1.1" 200 276

the "&" sign can at times be more or less. When this is divided, it will be written again as single URLs with the same begin and end data. eg:

130.73.63.88 - - [17/Sep/2002:13:51:57 +0200] "GET /V/SU3R23N8D8VN1416RL24TG4NU8AD6GP21IAGVXTSEHJC74JT7Q-01411/find-1? BASE=TFH_WILDAU HTTP/1.1" 200 276


130.73.63.88 - - [17/Sep/2002:13:51:57 +0200] "GET /V/SU3R23N8D8VN1416RL24TG4NU8AD6GP21IAGVXTSEHJC74JT7Q-01411/find-1? BASE=HUB01& HTTP/1.1" 200 276

130.73.63.88 - - [17/Sep/2002:13:51:57 +0200] "GET /V/SU3R23N8D8VN1416RL24TG4NU8AD6GP21IAGVXTSEHJC74JT7Q-01411/find-1? BASE=TFH_WILDAU HTTP/1.1" 200 276

130.73.63.88 - - [17/Sep/2002:13:51:57 +0200] "GET /V/SU3R23N8D8VN1416RL24TG4NU8AD6GP21IAGVXTSEHJC74JT7Q-01411/find-1? BASE=FES01& HTTP/1.1" 200 276

130.73.63.88 - - [17/Sep/2002:13:51:57 +0200] "GET /V/SU3R23N8D8VN1416RL24TG4NU8AD6GP21IAGVXTSEHJC74JT7Q-01411/find-1? FIND_REQUEST_1=JAVA& HTTP/1.1" 200 276

new extra URLs will be generated with respect to the number of splited pieces.
has anyone ever done this or does anyone has an Idea on how this can be done?
Please I rely on you.
Remi


Paul
Enthusiast

Oct 9, 2002, 6:59 AM

Post #2 of 3 (356 views)
Re: [remi] Splitting a URL into parts [In reply to] Can't Post

You can split simply by using the perl "split" function.

my @pairs = split '&', $url;


remi
Novice

Oct 10, 2002, 1:52 AM

Post #3 of 3 (349 views)
Re: [RedRum] Splitting a URL into parts [In reply to] Can't Post

Thanks for the advice. my main problem is to get this splitted urls as new lines including the same IPs and the rest of the line.
That is using it more than one time in the line and just exchanging the splited part.
Help please...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives