Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-11-19 03:24 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (278 votes). Check out past polls.