Error: ...undefined value "$Server->MapPath("

Posted by venkeykanle on 2018-10-26 08:08

Hi - Im a newbie and this sample test throws this error:
Can't call method "MapPath" on an undefined value at F:\Test\TestAbout.pl line 6.

If I remove line 6, I get "test" printed.

The is a sample code:

use strict;
use warnings;
use vars qw($Request $Response $Application $Server $Session);

my $path="test";
$path = $Server->MapPath(".");
print $path;

grahams
ActiveState Staff
Mon, 2018-10-29 08:25

"." is an operating system shortcut. The O/S understands what you mean, but Perl does not.

You could pass "." to the system to be evaluated, but it's generally better (fewer opportunities for things to go wrong) to find the current directory using Perl.

https://perldoc.perl.org/Cwd.html