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.
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.