Fellow Monks,

I'm currently converting a templating system that has HTML mixed up with Perl code (yuck!) with HTML::Template.

I'm currently doing this in a few steps:

1) Convert my code in HTML::Template code inline

2) Moving this inline code into a separate file in a separate directory

#1 Was nothing. Cake. All done.

#2 is more difficult, as I don't want to have another Config variable need to be set for my program.

My idea for a solution to this problem was to store the templates in a directory below where my module is, for example, if the module is at:

myprogram/lib/Stuff/MyTemplate.pm

I wanted the templates to be at:

myprogram/lib/Stuff/templates

(at the moment, I don't want the templates servicable, only outside of my program's Perl code)

My idea for a solution to this problem was to find the absolute path of where the Templating functions are (in this case, they're in a separate module, not a part of the *.cgi file)

The problem with this route is that I can't for the life of me, figure out how to find the absolute path to my module; __FILE__ only stores something like,

lib/Stuff/MyTemplate.pm,

not

/home/me/lib/stuff/MyTemplate.pm

This:

use File::Spec; print File::Spec->rel2abs(__FILE__);
Gives the same thing.

So, is there a way to find the absolute path to a module, from the module's, perspective (not from the perspective of the perl script which will use()/require() it)?

 

-justin simoni
!skazat!


In reply to 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.