Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Can't find relative path

by NetWallah (Canon)
on Mar 24, 2012 at 20:43 UTC ( #961437=note: print w/replies, xml ) Need Help??

in reply to Can't find relative path

Try adding this to your code:
print "<b>$_</b>: $ENV{$_}<br>\n" for sort keys %ENV;
You should see the variables SCRIPT_TRANSLATED and SCRIPT_NAME, which contain the information you need.
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
    Thanks, but the question isn't how to fix it in the code; I have several solutions for that. The question is why it's happening on this server and not on my previous (shared hosting) servers. Problem is I have a couple hundred previously-built Perl modules that expect to see a relative path, and I don't want to have to go through & rewrite them all if there's a way to fix Perl or the server to actually use the relative path.
      How about adding a symbolic link on the server, from the directory it is trying to access, to the directory where the data is ?

                   All great truths begin as blasphemies.
                         ― George Bernard Shaw, writer, Nobel laureate (1856-1950)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961437]
and !@monks...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2018-02-25 16:05 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (314 votes). Check out past polls.