Does a Perl module know where it is installed?

Posted by CoffeeMonster on Stack Overflow See other posts from Stack Overflow or by CoffeeMonster
Published on 2009-04-13T05:54:26Z Indexed on 2010/04/03 8:23 UTC
Read the original article Hit count: 207

Filed under:
|
|

Hi Perl programmers,

I have started creating a Perl package that contains a default email template.

The MANIFEST looks something like:

SendMyEmail.pm
SendMyEmail/defualt_email.tt

Currently I know where the module (and the template) are - but does the module itself know where on disk it is? So could the module find the default template without my help?

# This is what I would like to do.
package SendMyEmail;
sub new {
    my ($self, $template) = @_;
    $template ||= $dir_of_SendMyEmail .'/SendMyEmail/default_email.tt'; # ??
}

Is there a better way of including a templates text, or a better place to put the template?

Any references to CPAN modules that do something similar would be welcome.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about perl

Related posts about template