in reply to Re: Tutorial on making a proper module?
in thread Tutorial on making a proper module?

That tutorial is very good, thanks a lot for that. I will definitely follow it.

I have one specific question about the templates thing still unanswered though. Say I have a module like this, and there's an essential file right there in the same directory as TestModule.pm

package TestModule; open( FILE, '<', 'essential_file.txt' ) or die("Can't open file"); 1;

and I run it like this:

require TestModule; print "hello world";

It will fail (unless the script is in the same directory as TestModule).

I'm probably missing something obvious but how do I get the file path right so that TestModule.pm can find its file, no matter where it's called from?

Replies are listed 'Best First'.
Re^3: Tutorial on making a proper module?
by Anonymous Monk on Jan 14, 2016 at 04:39 UTC
      Is it still broken? This reply to the discussion you linked to hints otherwise.
      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        yes, like said there, still broken on all the old perls.... findbin isn't on cpan , findbin is only in perl, its not dual lived, thus all the old ones are broken

      OK that's more complex than I was hoping for, but that's very helpful, thanks.

      I might just stuff them into scalars and add another module to return them for the time being. Don't judge me!