Greetings, Experienced Perl Monks,

I have a number of perl scripts that I use for data maintenance. I would like to build a web front end for them (in PHP, since the site I'm assisting with uses it exclusively). The perl scripts are stored in /basedir/perl and the admin pages are stored in /basedir/admin.

My question is this: does Perl have anything like the dirname() function in PHP, that, when used thusly, dirname(__FILE__);, will return the absolute path to the script, no matter where it is included from?

I have subdirectories of perl scripts that reference external files, and when I access them from PHP pages, the different working directory breaks it. I can't hardcode the paths, since it's a small component of a large project set up in a test directory. I also do not want to program in paths relative to the including pages, as I want the files to be still useful from the commandline.

I have tried using Cwd and Config::Find::Where. The latter works somewhat, but only on the outermost level: if I try to access a perl script that includes another one in another folder, Config::Find::Where cannot grok the path for that internal file.

Is there an obvious solution to this that I am missing?

Thanks a bundle,
Andy


In reply to Relative paths in included files by a,s5

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.