ASPEER-MakeMaker
view release on metacpan or search on metacpan
lib/ASPEER/MakeMaker/MM/Util.pm view on Meta::CPAN
=begin markdown
# ASPEER::MakeMaker::MM::Util
## Name
ASPEER::MakeMaker::MM::Util - shared utility functions for MakeMaker helpers
## Synopsis
```perl
use ASPEER::MakeMaker::MM::Util;
msg('building %s', $name);
my $text = slurp($file);
blurp($file, $text);
my $param = arg(@make_target_args);
my $perlrun = perlrun($hook_object, $make_maker_object);
```
## Description
`ASPEER::MakeMaker::MM::Util` exports support functions used by the rest
of the distribution. The helpers cover formatted messages, debugging, simple
file I/O, MakeMaker target argument parsing, and construction of a Perl command
for generated make targets.
All listed functions are exported by default.
## Functions
### quiet_enable
```perl
quiet_enable();
quiet_enable($value);
```
Enables quiet mode. When quiet mode is active, `msg` and `verbose` output is
suppressed.
### verbose_enable
```perl
verbose_enable();
verbose_enable($value);
```
Enables verbose output for `verbose`.
### debug_enable
```perl
debug_enable($value);
```
Sets the debug flag used by `debug`.
The module also enables debug mode at load time if an environment variable
named after the current script plus `_DEBUG` is set.
### msg
```perl
msg('message %s', $value);
```
Prints a formatted message to standard error unless quiet mode is enabled.
### verbose
```perl
verbose('message %s', $value);
```
Prints a formatted message to standard error only when verbose mode is enabled
and quiet mode is not enabled.
### debug
```perl
debug('message %s', $value);
```
Prints a debug message to standard error when debug mode is enabled. The output
includes caller package, method, and line information.
### err
```perl
err('unable to process %s', $file);
```
Prints a formatted error message and croaks.
### slurp
```perl
my $text = slurp($file);
```
Reads and returns the full contents of a file using `IO::File`. On failure,
calls `err`.
### blurp
```perl
blurp($file, $text);
```
Writes text to a file, replacing any existing content. Open, write, and close
failures call `err`.
### touch
```perl
touch($file);
```
Ensures a file exists. If the file is missing, creates it as an empty file.
lib/ASPEER/MakeMaker/MM/Util.pm view on Meta::CPAN
=end markdown
=head1 ASPEER::MakeMaker::MM::Util
=head2 Name
ASPEER::MakeMaker::MM::Util - shared utility functions for MakeMaker helpers
=head2 Synopsis
use ASPEER::MakeMaker::MM::Util;
msg('building %s', $name);
my $text = slurp($file);
blurp($file, $text);
my $param = arg(@make_target_args);
my $perlrun = perlrun($hook_object, $make_maker_object);
=head2 Description
C<ASPEER::MakeMaker::MM::Util> exports support functions used by the rest
of the distribution. The helpers cover formatted messages, debugging, simple
file I/O, MakeMaker target argument parsing, and construction of a Perl command
for generated make targets.
All listed functions are exported by default.
=head2 Functions
=head3 quiet_enable
quiet_enable();
quiet_enable($value);
Enables quiet mode. When quiet mode is active, C<msg> and C<verbose> output is
suppressed.
=head3 verbose_enable
verbose_enable();
verbose_enable($value);
Enables verbose output for C<verbose>.
=head3 debug_enable
debug_enable($value);
Sets the debug flag used by C<debug>.
The module also enables debug mode at load time if an environment variable
named after the current script plus C<_DEBUG> is set.
=head3 msg
msg('message %s', $value);
Prints a formatted message to standard error unless quiet mode is enabled.
=head3 verbose
verbose('message %s', $value);
Prints a formatted message to standard error only when verbose mode is enabled
and quiet mode is not enabled.
=head3 debug
debug('message %s', $value);
Prints a debug message to standard error when debug mode is enabled. The output
includes caller package, method, and line information.
=head3 err
err('unable to process %s', $file);
Prints a formatted error message and croaks.
=head3 slurp
my $text = slurp($file);
Reads and returns the full contents of a file using C<IO::File>. On failure,
calls C<err>.
=head3 blurp
blurp($file, $text);
Writes text to a file, replacing any existing content. Open, write, and close
failures call C<err>.
=head3 touch
touch($file);
Ensures a file exists. If the file is missing, creates it as an empty file.
=head3 arg
my $param = arg(@args);
Parses the fixed argument sequence passed by generated make targets into a hash
( run in 0.558 second using v1.01-cache-2.11-cpan-234fa220139 )