NAME
Module::Install::Substitute - substitute values into files before install
SYNOPSIS
... Makefile.PL ...
substitute(
{
LESS => '/usr/bin/less',
APXS => '/usr/bin/apxs2',
},
'bin/my-app'
);
... bin/my-app ...
### after: my $less_path = '@LESS@';
my $less_path = '/usr/bin/less';
DESCRIPTION
This is extension for Module::Install system that allow you to substitute values into files before install, for example paths to libs or binary executables.
METHODS
substitute {SUBSTITUTIONS} [{OPTIONS}] @FILES
Takes a hash reference with substituations key value pairs, an optional hash reference with options and a list of files to deal with.
Options
Several options are available:
- sufix
-
Sufix for source files, for example you can use sufix
.in
and results of processing of Makefile.in would be writen into file Makefile. Note that you don't need to specify sufixes in the list of files. - from
-
Source base dir. By default it's the current working directory (Cwd). All files in the list are treated as relative to this directory.
- to
-
Destination base dir. By default it's the current working directory (Cwd).
File format
In the files the following constructs are replaced:
###\s*after:\s?some string with @KEY@
some string with @KEY@
some string with value
###\s*before:\s?some string with @KEY@
###\s*replace:\s?some string with @KEY@
So string should start with three # characters followed by optional spaces, action keyword and some string where @SOME_KEY@ are substituted.
This module can replace lines after or before above constructs based on action keyword to allow you to change files in place without moving them around and to make it possible to run substitution multiple times.
AUTHOR
Ruslan Zakirov <ruz@cpan.org>