Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Make munging File::FromCode and File::InMemory easier

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 t
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .perltidyrc
Octocat-spinner-32 Changes
Octocat-spinner-32 README.mkdn
Octocat-spinner-32 dist.ini
Octocat-spinner-32 perlcritic.rc
Octocat-spinner-32 weaver.ini


Dist::Zilla::Util::SimpleMunge - Make munging File::FromCode and File::InMemory easier.


version 0.2.2


use Dist::Zilla::Util::SimpleMunge qw( munge_file munge_files );

sub somesub {
  munge_file $file_from_zilla, {
    via => sub {
      my ( $file, $content ) = @_;
      ... mangle $content here ...;
      return $mangled;



# munge_file ( $FILE , \%CONFIGURATION )

    via => sub { ... },
      lazy => $laziness


A ::Role::File object to munge.


  via => $CODEREF,
  lazy => $LAZINESS,


Called to munge the file itself.

Passed a reference to the ::Role::File instance, and a scalar containing the contents of that file.

Return new content for the file via return

sub {
  my ( $file, $content ) = @_ ;
  return $newcontent;


Specify how lazy you want the munge to be performed. Normally, what this is set to is dependent on the type of file being munged.

$LAZINESS = undef ;  # use default for the file type
$LAZINESS = 0     ;  # Munge immediately
$LAZINESS = 1     ;  # Defer munging till as late as possible.

For things that are normally backed by scalar values, such as ::File::OnDisk and ::File::InMemory , the laziness is equivalent to $LAZINESS = 0, which is not lazy at all, and munges the file content immediately.

For things backed by code, such as ::File::FromCode , munging defaults to $LAZINESS = 1, where the actual munging sub you specify is executed as late as possible.

You can specify the $LAZINESS value explicitly if you want to customize the behaviour, i.e.: Make something that is presently a scalar type get munged as late as possible ( converting the file into a FromCode file ), or make something currently backed by code get munged "now", ( converting the file into a InMemory file )


This is mostly a convenience utility for munging a lot of files without having to hand-code the looping logic.

It basically just proxies for "munge_file".

# munge_files ( \@FILEARRAY , \%CONFIGURATION )

munge_files( [ $zilla_file_one, $zilla_file_two, ], {
  via => sub { ... },
  lazy => $laziness,


An ArrayRef of "$FILE"

See Also


Kent Fredric


This software is copyright (c) 2013 by Kent Fredric

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Something went wrong with that request. Please try again.