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

Calling a subroutine using $ENV{'DOCUMENT_ROOT'}

Status
Not open for further replies.

TimmyC

Technical User
Dec 3, 2002
1
US
I'm having trouble calling my subroutines with a variable.

My website is hosted on a virtual server; as such my absolute path on the server is subject to change from time to time. The company provided the following environment variable for use when a CGI script calls for my absolute path:

$ENV{'DOCUMENT_ROOT'}

I am trying to use a scalar variable as the argument for the require function.

I set up the following scripts to call a subroutine. When I run the script I get an error message saying the document contains no data.

Here's the main script:

#!/usr/local/bin/perl -wT
print "Content-type: text/html\n\n";
use strict;
use CGI ':standard';

my $path = qq($ENV{'DOCUMENT_ROOT'}cgi/library.lib);

require qq($path);

test();

Here's the library script:

sub test{

print qq(Hello, it works.);
}

1;

You can view the error message at
Does anyone know why this won't work?

NOTE: I printed the $path variable, then I cut and pasted it from the screen, and used that for the require argument and it worked fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top