---
name: "Module::Install::Substitute"
section: "3pm"
platform: "linux"
package: "libmodule-install-substitute-perl"
version: "0.03-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Module::Install::Substitute"
---

# Module::Install::Substitute(3pm)

substitute values into files before install

## 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

Module::Install::Substitute is an extension for Module::Install system that allows 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 substitutions 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 written 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\>

##
