Quote: BTW - an absolute path has no "perspective", its an absolute path.

What I meant by that statement is that I don't want the absolute path of the script that's calling the module, I want the absolute path of the module the script is calling - that's the difference in perspective.

Quote: Try it again, because that works. If it doesn't work for you, upgrade File::Spec.

Well, here's proof of what you're saying, I give you FOO.pm:

package FOO; use File::Spec; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(bar); sub bar { print File::Spec->rel2abs(__FILE__) . "\n"; } 1;
And here's a test cgi script:
#!/usr/bin/perl use FOO; use CGI qw(:standard); print header(); FOO::bar();

Prints: /home/user/www/cgi-bin/test.pl

But (of course, sigh), my not as tiny program is still giving me the not-so-absolute path. It's almost as if it thinks the absolute path *starts* at the lib directory.

Hmm. I'll come post back if I can figure something else out, must be some weird gremlin hunting about.

 

-justin simoni
!skazat!


In reply to Re^2: finding the absolute path to a module, from the module's, perspective by skazat
in thread finding the absolute path to a module, from the module's, perspective by skazat

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.