in reply to Can't find relative path
Try adding this to your code:
SCRIPT_NAME is essentially the host absolute URL (minus the scheme, host, and port) for script, and SCRIPT_TRANSLATED is the corresponding physical file.
You can extract the path from these, and use that to prefix your "data/file.txt" before opening it.
You should see the variables SCRIPT_TRANSLATED and SCRIPT_NAME, which contain the information you need.print "<b>$_</b>: $ENV{$_}<br>\n" for sort keys %ENV;
SCRIPT_NAME is essentially the host absolute URL (minus the scheme, host, and port) for script, and SCRIPT_TRANSLATED is the corresponding physical file.
You can extract the path from these, and use that to prefix your "data/file.txt" before opening it.
All great truths begin as blasphemies.
― George Bernard Shaw, writer, Nobel laureate (1856-1950)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Can't find relative path
by Anonymous Monk on Mar 24, 2012 at 23:03 UTC | |
by NetWallah (Canon) on Mar 25, 2012 at 00:44 UTC |
In Section
Seekers of Perl Wisdom