in reply to Relative paths in included files

I'm a tad confused. Do you want the exact path location of the perl script itself? You use FindBin to find that, to quote from the synopsis:
use FindBin; use lib "$FindBin::Bin/../lib"; or use FindBin qw($Bin); use lib "$Bin/../lib";
If you want to know the exact path of modules you're including, the %INC hash should have that.

Replies are listed 'Best First'.
Re^2: Relative paths in included files
by a,s5 (Initiate) on Jun 05, 2004 at 02:33 UTC
    Yes! That's exactly what I was looking for. Thank you very much.

    Andy

      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