Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Including text files in Modules

by tfrayner (Curate)
on Nov 05, 2004 at 16:58 UTC ( #405548=note: print w/replies, xml ) Need Help??

in reply to Including text files in Modules


I've just had to figure this out myself recently. The following feels like a bit of a hack, but it does work:

use File::Spec # NB. File::Spec isn't actually required, # but it's a good cross-platform solution my @module_dir_array = File::Spec->splitpath(__FILE__); my $filename = File::Spec->catpath(@module_dir_array[0,1],'file.txt'),
It uses the __FILE__ literal which always points at the current filename (see perldoc perldata). So you can put your file.txt file in the same directory as your and the module should always be able to find it.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://405548]
[Corion]: I stay home today as preventative measure to not really get a cold. On the upside, I can sit on the balcony in the sun, and it isn't that cold, at least once I don a thick coat :)
[marto]: you have a balcony on the Sun?
marto ducks
[Discipulus]: bravo! orange juice will help

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2018-03-21 11:08 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.