Guest User

Untitled

a guest
Jun 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. SendMyEmail.pm
  2. SendMyEmail/defualt_email.tt
  3.  
  4. # This is what I would like to do.
  5. package SendMyEmail;
  6. sub new {
  7. my ($self, $template) = @_;
  8. $template ||= $dir_of_SendMyEmail .'/SendMyEmail/default_email.tt'; # ??
  9. }
  10.  
  11. my $DEFAULT_TEMPLATE;
  12. BEGIN {
  13. $DEFAULT_TEMPLATE = __FILE__;
  14. $DEFAULT_TEMPLATE =~ s,.pm$,/default_email.tt,;
  15. }
  16.  
  17. package Foo::Bar;
  18.  
  19. use Cwd qw(abs_path);
  20. use File::Basename qw(dirname);
  21.  
  22. sub module_dir { abs_path(dirname(__FILE__)) }
  23.  
  24. 1;
  25.  
  26. use Foo::Bar;
  27.  
  28. print Foo::Bar->module_dir, "n";
  29.  
  30. ## load the module
  31. use Data::Dumper;
  32.  
  33. ## output full path to Data::Dumper module loaded
  34. print $INC{'Data/Dumper.pm'};
  35.  
  36. ## see which module was loaded (if you have multiple folders with same modules)
  37. print Dumper(%INC);
  38.  
  39. perlwhere() {
  40. perl -wle'eval "require $ARGV[0]" or die; ($mod = $ARGV[0]) =~ s|::|/|g; print $INC{"${mod}.pm"}' $1
  41. }
Add Comment
Please, Sign In to add comment