skieros wrote:
> open(FILE, ">>/some_folder/some_sub_folder/digest.passwd") or die $!;
> print FILE "$user:$realm:" . Digest::MD5::md5_hex("$user:$realm:
> $pass") . "\n";
> close(FILE);
>
> Hello i have the above code that i have changed from absolute hdd path
> to a relative to a web server path, but after the change the file
> cannot be opened.
>
> Problem is that cause of the script runnign both in localhost and
> remote server
> i cant specify the same absolute path so i need some relativity here.
>
> I could use a varibale after determiantion of *where* the scrpt is
> running, that is which host, but i want to accomplish it with a
> relative path. Is this possible?!
>
It'll depend on your webserver, but something like
use strict;
use warnings;
my %paths = (
relative => q(some_folder/asdf.txt),
absolute => q(/other_path/some_folder/asdf.txt),
);
my $filepath;
if($ENV{SERVER_NAME} eq 'localhost'){
$filepath = $paths{relative};
}else{
$filepath = $paths{absolute};
}
open my $file,">>",$filepath or die $!;
|