RFC: New module 'Module::Bundled::Files'
- From: "Paul Campbell" <kemitix@xxxxxxxxx>
- Date: 26 Aug 2005 15:49:04 -0700
I've written a module, tentatively named Module::Bundled::Files. A
section of the POD docs is included to (attempt) to explain it's
purpose. It was inspired by the __tt_template_name() function in
CGI::Application::Plugin::TT.
I'm looking for any comments, particularly if anyone can suggest a
better name for the module.
Darcs repo and tar.gz is available at
http://kemitix.net/repos/module-bundled-files/
Thanks,
Paul
NAME
Module::Bundled::Files - Access files bundled with Module
VERSION
Version 0.01
SYNOPSIS
Access files installed with your module without needing to
specify an
install location on the target filesystem.
Setup
In Build.PL:
my $build = new Module::Build(...);
map{$build->add_build_element($_);}
qw{txt html tmpl};
# installs all .txt, .html and .tmpl files in the lib/ tree
Object-Oriented Interface
use base qw{Module::Bundled::Files};
if($self->mbf_exists('data.txt')){...}
my $filename = $self->mbf_path('data.txt');
open my $fh, '<', $filename or die $@;
my $fh = $self->mbf_open('data.txt');
while(<$fh>)
{
...
}
my $data = $self->mbf_read('data.txt');
Non-Object-Oriented Interface
use Module::Bundled::Files qw{:all};
my $object = new Other::Object;
if(mbf_exists($other,'otherfile.txt')){...}
my $filename = mbf_path($object,'otherfile.txt');
open my $fh, '<', $filename or die $@;
my $fh = mbf_open($object,'otherfile.txt');
while(<$fh>)
{
...
}
my $data = mbf_read($object,'otherfile.txt');
DESCRIPTION
This module provides an simple method of accessing files that
need to
be bundled with a module.
For example, a module My::Module, which needs to access a
seperate file
data.txt.
In your development directory you would place your data.txt in
your
lib/My/Module/ directory.
lib/
My/
Module.pm
Module/
data.txt
Using add_build_element(...) in your Build.PL file allows the
data.txt
file to be installed in the same relative location.
The file(s) can then be accessed using the mbf_* functions
provided by
this module.
.
- Follow-Ups:
- Re: RFC: New module 'Module::Bundled::Files'
- From: Slaven Rezic
- Re: RFC: New module 'Module::Bundled::Files'
- Prev by Date: Re: UNIVERSAL::can function failing under heavy load
- Next by Date: writing modules in 'c'
- Previous by thread: UNIVERSAL::can function failing under heavy load
- Next by thread: Re: RFC: New module 'Module::Bundled::Files'
- Index(es):
Relevant Pages
|
|