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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass variable in .pl file

Status
Not open for further replies.

smavtron

Technical User
Jul 28, 2007
17
US
I don't have knowledge on perl.... I have completed the same in php and works, now want to do the same in .cgi

I am trying to pass the variable "q" in the example below

Code:
/cgi-bin/search/search.pl?p=1&lang=en&include=&exclude=&penalty=0&mode=all&q=dell

in code

Code:
<iframe height="600" width="160" frameborder="0" marginheight="0" marginwidth="0" src="[URL unfurl="true"]http://ah.pricegrabber.com/export_feeds.php?pid=ahhfbbd&document_type=html&topcat_id=all&category=topcat:all&banner_size=160x600&form_keyword=<====[/URL] Here is where the variable will get declared" =====>>&banner_bgcolor=ffffff&show_images=1&iframe=1" scrolling="No" ></iframe>

The same I was able to do in php by <?php echo $_GET["q"]; ?>

Please suggest.
 
Hi feherke,

Thanks for thr reply. I tried

Code:
print param('q');

it just displays exactly the same content "print param('q');" instead of printing the variable.

As mentioned I do not know anything in perl... can you please walk me through your suggestion "Or you can extract the parameter from the QUERY_STRING environment variable."

TIA.
 
Hi

Well, if you know nothing about Perl, better stay with using the [tt]CGI[/tt] module. Then I post a fully functional piece of code :
Code:
#!/usr/bin/perl

use CGI qw/:standard/;

print header;

print param('q');
That works for me. This supposes that my web server is configured to run CGI scripts, my [tt]perl[/tt] executable is in the place indicated by the shebang, the [tt]CGI[/tt] module is installed and can be found in one of the directories indicated by [tt]@INC[/tt] and my script has execute permission for the web server's user.

Feherke.
 
Look at feherke, the letters "CGI" are a link to the CGI documentation. Read the documentation. It is not hard to understand.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
You could be correct, but a web server that does not have perl installed is pretty rare but not unheard of. Most likely they just have no idea how to run a perl based cgi script and are doing something fundamentally wrong.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thanks for all the replies. We are using perlfect 3.2 for seach scripts. The way it works is that <iframe....> script is in templates/search.html and gets pulled in search.pl.

I am not sure how the coding is done.

I may to did more it seems to first understand how the script works... any ideas?
 
thanks for all the help and input.... solved with calling teh variable as <!--cgi: query_str-->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top