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

require with conditions

Status
Not open for further replies.

forces1

Programmer
Apr 5, 2007
29
NL
Hi all,

I've tried to include a perl-file while running another perl-file. First of all I don't know if it works and if I've used the require-function the right way:

Code:
require "/home/admin/domains/zoekmach1ne.nl/public_html/MTS4/cgi/nph-testsearch.cgi";

The reason why I don't know if this function works, is that it needs conditions to work, like when you open the file with: "nph-testsearch.cgi?query_string=test".

Now my question is: Can I also include those conditions with the require-function? I've figured out yet that

Code:
 require "/home/admin/domains/zoekmach1ne.nl/public_html/MTS4/cgi/nph-testsearch.cgi?query_string=test";
doesn't work.

Thanks for your help.
 
I think you want a system call
$output = `/path/to/script options`;

print "$output\n";

if you are using the CGI module you can just pass
/path/to/script option=value



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Code:
if (some_condition) {
   require "some_module";
}
[code]


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thanks for reacting.

@travs69: Do you mean that I can just use the code like this:
Code:
require "/home/admin/domains/zoekmach1ne.nl/public_html/MTS4/cgi/nph-testsearch.cgi query_string=test";
Because it is a CGI-module I want to use.


@KevinADC: Will it work when I use:
Code:
if (query_string == test) {  require "/home/admin/domains/zoekmach1ne.nl/public_html/MTS4/cgi/nph-testsearch.cgi";
}
Because then the nph-testsearch can't use the condition, right? Or is that not what you ment?

Thanks for your help!
 
No. You have to import the query string data into your perl script first. The CGI module is most commnly used for such purpose. Then when you have the query string data stored in some perl variables you use the corresponding variable:

Code:
if ($foo eq 'test') {
   require "yourmodule";
}

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top