By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,285 Members | 2,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,285 IT Pros & Developers. It's quick & easy.

Passing variable in a hyperlink to a Perl script

P: 19
I am creating a web site where I want to have a hyperlink that executes a Perl script. At the same time, I want to pass along a variable inside of the hyperlink that the Perl script can use when it executes.

I don't want to use a form unless it is necessary.

The hyperlink might look like this:

<a href=get_info.pl?variable="chicken">I like fried chicken</a>

So, when the user clicks on the link, the Perl script named "get_info.pl" would know that the variable equals "chicken".

Any suggestions or tips are appreciated.

Thanks,

Tony
Aug 24 '07 #1
Share this Question
Share on Google+
5 Replies


KevinADC
Expert 2.5K+
P: 4,059
use the CGI module to parse the query string:

perldoc: CGI module
Aug 24 '07 #2

P: 19
I understand that I need to use the CGI module, but what I am looking to do is to create a hyperlink that executes a Perl script.

Currently, if I have a hyperlink like this:

<a href=get_invoice.pl>Get Invoice</a>

the output is nothing but the Perl script as text. The script doesn't get executed.

Thanks
Aug 25 '07 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
I am not really sure you can do that. Hyperlinks are supposed to be links to other pages or documents.

One thing you could do is create a quick, small form, maybe just a button, that says "Display Invoice" and when the button is clicked, the invoice is displayed.

Regards,

Jeff
Aug 25 '07 #4

KevinADC
Expert 2.5K+
P: 4,059
hyper links can execute scripts, just include the correct url:

<a href="cgi-bi/get_invoice.pl">Get Invoice</a>

if the script displays instead of executing you are using it in the wrong folder or the server is not setup corectly.
Aug 25 '07 #5

P: 19
My problem was that I wasn't putting this in the script to tell the browser to expect html...

print "Content-type: text/html\n\n<html>";

Thanks.
Aug 26 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.