Eugene Grigoriev
and 1 contributors

NAME

File::Dir::Map - Map a directory recursively

VERSION

Version 0.01

SYNOPSIS

The following snippet summarizes what File::Dir::Map does.

Files are copied from src to build dirs such that files with extension ignore will not be copied, files with extension markdown will get processed by markdown and saved in build dir, and files with extension raw are guaranteed to be copied without processing but stripped of the raw extension.

    use File::Dir::Map qw(dirmap);
    use Text::MultiMarkdown qw(markdown);
    
    dirmap src => build => {
        ignore => sub{ [] },
        raw    => sub{
            my( $name, $content ) = @_;
            [ $name, $content ];
        },
        markrown => sub{
            my( $name, $contnet ) = @_;
            [ "$name.html", markdown $content ]
        },
    };

So this before the map:

  src/pages/todo.ignore
  src/pages/index.markdown
  src/pages/about.html
  src/pages/index.markdown.raw
  src/files/
  build/some/junk/here.txt

Will be this after the map:

  src/pages/todo.ignore
  src/pages/index.markdown
  src/pages/about.html
  src/pages/index.markdown.raw
  src/files/
  build/pages/index.html
  build/pages/about.html
  build/pages/index.markdown
  build/files/

Note that old build directory is purged!

EXPORT

dirmap

SUBROUTINES/METHODS

dirmap $dir_from, $dir_to, $funcs

$funcs is a hashref with file extensions as keys and mapping functions as values.

Each mapping function takes two arguments: filename stripped of the extension and file contents.

Each mapping function should return a listref that's either empty or contains two elements: new filename and new content. In case the listref is empty, file will not be saved in the destination directory.

AUTHOR

Eugene Grigoriev, <perl at sizur.com>

BUGS

Please report any bugs or feature requests to bug-file-dir-map at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Dir-Map. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc File::Dir::Map

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2010 Eugene Grigoriev.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.