/Devel-Rewrite

Development preprocessor for perl code

Primary LanguagePerlOtherNOASSERTION

NAME
    Devel::Rewrite - Development preprocessor

SYNOPSIS
        # Your::Module:

        # @rewrite s/^#\s+//;
        # use Some::Development::Module;

        # @rewrite s/some_call/another_call/;
        $object->some_call;

        sub something {
        # @include sub.debug.inc
        ...
        }

    And in author tests:

        # xt/some-development-test.t:
        use strict;
        {
        use Devel::Rewrite;
        use Modules::That::Should::Be::Rewrited;
        }
        use Modules::Other;

        # make your tests...

    Also this module implements pragmatic behaviour.

        use Devel::Rewrite;
        use Module1; # rewrite enabled;
        {
        no Devel::Rewrite;
        use Module2; # rewrite disabled;
        {
            use Devel::Rewrite;
            use Module3; # rewrite enabled;
        }
        use Module4; # rewrite disabled;
        }
        use Module5; # rewrite enabled;

DESCRIPTION
    The main purpose of this module is creating optional debugging routines.

    - which does not require any additional prerequsites for production,
    like for ex Devel::Leak::Cb

    - which does not provide any perfomance overhead in production
    enveronment.

    - which requires no rebuild of target modules for enabling debugging
    routines

    In other words, this module is external source filter, for any loading
    modules

IMPORTANT NOTICE
    This module overloads "CORE::GLOBAL::require" on "import". Since this is
    module loading endpoint, it won't call any previously overloaded

    So, if you use something, like as, load this package earlier, than as

    Also, please, don't use this module inside your modules. Only in
    external scripts and applications. That's because there is no way to
    change the behaviour of "use"'d module inside your sources

DIRECTIVES
    @include filename
        Include source of "filename" into directive place. Rewrite
        subprocessing of include will be done. "filename" should be relative
        to file, which call @include

        # Module.pm:
        sub yoursub {
            my @args = @_;
            # @include debug.inc
            ...
        }
        # debug.inc:
        warn "Entered sub";

    @rewrite EXPR
        Call EXPR in context of next non-empty source line

        sub test {

            # @rewrite s/'not\s+/'/;

            return 'not rewritten';

        }

        If next non-empty line is another directive, rewrite is ifnored and
        warning is emitted

AUTHOR
    Mons Anderson, "<mons@cpan.org>"

SUPPORT
    You can look for information at:

    *   RT: CPAN's request tracker

        <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Rewrite>

    *   AnnoCPAN: Annotated CPAN documentation

        <http://annocpan.org/dist/Devel-Rewrite>

    *   CPAN Ratings

        <http://cpanratings.perl.org/dist/Devel-Rewrite>

    *   Search CPAN

        <http://search.cpan.org/dist/Devel-Rewrite/>

    *   GitHub

        <http://github.com/Mons/Devel-Rewrite>

COPYRIGHT & LICENSE
    Copyright 2010 Mons Anderson.

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