DESCRIPTION

This is a role for Dist::Zilla::Role::File objects which gives you a mechanism for detecting and acting on files changing their content. This is useful if your plugin performs an action based on a file's content (perhaps copying that content to another file), and then later in the build process, that source file's content is later modified.

METHODS

on_changed($subref)

Provide a method to be invoked against the file when the file's content has changed. The new file content is passed as an argument. If you need to do something in your plugin at this point, define the sub as a closure over your plugin object, as demonstrated in the "SYNOPSIS".

Be careful of infinite loops, which can result if your sub changes the same file's content again! Add a mechanism to return without altering content if particular conditions are met (say that the needed content is already present, or even the value of a particular suitably-scoped variable.

METHODS

watch_file

Once this method is called, every subsequent change to the file's content will result in your on_changed sub being invoked against the file. The new content is passed as the argument to the sub; the return value is ignored.