Krang! No, sorry to reply to my own post here. It doesn't quite work.

The FindBin::Real module does an admirable job of finding the directory for the calling script. But if there are any files included that use it, it fails in them. I want to find something that works an arbitrary number of levels deep. Here's the situation:

/test.pl
(in this context, Bin() should return '/')
('require's Bin()/config.pl and Bin()/scrape_courses/scrape_courses.pl)

/scrape_courses/scrape_courses.pl
(in this context, I want Bin() to return '/scrape_courses')
('require's Bin()/../config.pl and Bin()/scrape_courses.template)

When I run test.pl, it gives me this error Cannot find current script './test.pl' at /scrape_courses/scrape_courses.pl line 30

So it's still not doing just what I need: every file, 'require'd some arbitrary number of levels deep, needs to know the full path to itself without being hard coded.

Thanks,
Andy


In reply to Re^3: Relative paths in included files by a,s5
in thread 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.