|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
I need help getting a cgi script to stop using the ?. I have found an open sorce script that does this but I am very new to perl and need help figuring out how to clean up this code so it can be integrated into mine, and also figuring out what part of the code actually does what I want and which is extra.
There are two parts. The varible: <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> ## This variable changes the operation of the script drastically. ## If pod_usequery=1 then POD will expect to be called in the format ## of .../pod.cgi?dir=/Arts/Entertainment ## If pod_usequery=0 then POD will expect to be called in the format ## of .../pod.cgi/Arts/Entertainment $pod_usequery=1; [/code] And the code itself: <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> &pod_main; exit 0; sub pod_main { &pod_init; if ($pod_debug) { print "Content-Type:text/htmlnn<html><head><title>DEBUGGING</title></head>"; print "<body><h1 align="center">Debugging mode ON</h1><br>"; print "<ul><li>POD DMoz.Org version: $pod_version<br><li>CGI library version: ".$CGI::VERSION."<br><li>Perl version: ".$]."<br><li>Server software: ".$ENV{'SERVER_SOFTWARE'}."<br><li>CGI Revision:".$ENV{'GATEWAY_INTERFACE'}."<br></ul><hr>n"; print "<strong>Entering:</strong> <code>pod_main</code><br>n"; } # Build a char->hex map for (0..255) { $pod_escapes{chr($_)} = sprintf("%%%02X", $_); } $pod_output=""; $pod_q = new CGI; $pod_tag = $pod_q->param("tag"); $pod_referer=$ENV{'HTTP_REFERER'}; if ($pod_usequery=='1') { $pod_dir = $pod_q->param("dir"); #$pod_dir = $ENV{'QUERY_STRING'}; $pod_dir =~ s/%([dA-Fa-f]{2})/pack("C", hex($pod_1))/eisg; $pod_dirext = "?dir="; } else { $pod_dir=$ENV{'PATH_INFO'}; $pod_query_string=$ENV{'QUERY_STRING'}; if (length($pod_query_string)>0) { $pod_dir=$pod_dir."?$pod_query_string"; } $pod_dir =~ s/%([dA-Fa-f]{2})/pack("C", hex($pod_1))/eisg; $pod_dirext = ""; } $pod_which_dir = "http://dmoz.org"; if ($pod_debug) { print "<strong>Full path details:</strong> <code>$pod_fullpath$pod_dirext</code><br>"; } &pod_read_headers; if (defined($pod_logging)) { &pod_log_search($pod_cgi_search); } $pod_tag = $pod_q->param("tag"); $pod_validpage=0; $pod_output=$pod_output.&pod_page_header; $pod_cgi_content = &pod_get_first_page; if ($pod_validpage==0) { &pod_modify_content; } if ($pod_validpage==2) { &pod_redirect($pod_cgi_content); } else { $pod_output=$pod_output.&pod_page_footer; &pod_output($pod_output,$pod_expire_in); } if ($pod_debug) { print "<strong>Leaving:</strong> <code>pod_main</code><br>n"; }; } sub pod_output { if ($pod_debug) { print "<strong>Entering:</strong> <code>pod_output</code><br>n"; }; [/code] Any help with this would greatly be apreciated. Thanks JeremyL [This message has been edited by JeremyL (edited June 05, 2000).] |
|
#2
|
||||
|
||||
|
Getting rid of the ? in a cgi script you can simply substitue '?' from the input. eg: $test="why? what? when?" $test=~ s/?/ /g; #substitute ? from test variable.. print $test; ------------------ SR - shiju.dreamcenter.net "The fear of the LORD is the beginning of knowledge..." |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Getting rid of the ? in a cgi script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|