Output::Rewrite - Rewrite your script output.


Output-Rewrite documentation  | view source Contained in the Output-Rewrite distribution.

Index


NAME

Top

Output::Rewrite - Rewrite your script output.

VERSION

Top

Version 0.03

SYNOPSIS

Top

    use Output::Rewrite (
        rewrite_rule => {
            hoge => "fuga",
        }
    );
    print "hoge hogehoge\n";
    # fuga fugafuga

    


    


    use Output::Rewrite (
        rewrite_rule => {
            '(?<=\b)hoge(?=\b)' => "fuga",
        }
    );
    print "hoge hogehoge\n";
    # fuga hogehoge

    


    


    use Output::Rewrite (
        rewrite_rule => {
            '(\d)' => '$1!',
        }
    );
    print "1234 I love Marine Corps!\n";
    # 1!2!3!4! I love Marine Corps!

    


    use Output::Rewrite(
        modifiers => q/msgi/,
        rewrite_rule => {
            '(?-i)Sensitive' => 'SENSITIVE',
            'NoN sEnsItivE' => 'NON SENSITIVE',
        },
    );
    #or
    use Output::Rewrite;
    Output::Rewrite::rewrite_rule(
            '(?-i)Sensitive' => 'SENSITIVE',
            'NoN sEnsItivE' => 'NON SENSITIVE',
    );
    Output::Rewrite::modifiers('msgi');




DESCRIPTION

Top

Output::Rewrite helps you to rewrite your script output.

When you print(or write, syswrite, printf) to STDOUT, Output::Rewrite hooks output and rewrite this.

Set rewrite rule(regex) and regex modifiers(i,g,m,s,x) when you load this module,

    use Output::Rewrite (
        modifiers => 'ig',
        rewrite_rule => {
            'from' => 'to',
        }
    );

or with Output::Rewrite::rewrite_rule() and Output::Rewrite::modifiers().

    use Output::Rewrite;
    Output::Rewrite::modifiers('ig');
    Output::Rewrite::rewrite_rule(
        'from' => 'to',
    );

This module ties STDOUT so you must use carefully.

FUNCTIONS

Top

rewrite_rule

Accessor for rewrite rule.

    Output::Rewrite::rewrite_rule(
        'from' => 'to',
        'from' => 'to',
    );




modifiers

Accessor for substitution modifiers.(i,g,m,s,x) Default is 'g'.

    Output::Rewrite::modifiers('msgi');
    my $modifiers = Output::Rewrite::modifiers;

If you want to apply modifiers only one time, you can use (?imsx-imsx) instead of this. For example:

    use Output::Rewrite(
        modifiers => q/msgi/, 
        rewrite_rule => {
            '(?-i)Sensitive' => 'SENSITIVE',
            'NoN sEnsItivE' => 'NON SENSITIVE',
        },
    );




AUTHOR

Top

Hogeist, <mahito at cpan.org>, http://www.ornithopter.jp/

BUGS

Top

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

SUPPORT

Top

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

    perldoc Output::Rewrite

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Output-Rewrite

* CPAN Ratings

http://cpanratings.perl.org/d/Output-Rewrite

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Output-Rewrite

* Search CPAN

http://search.cpan.org/dist/Output-Rewrite

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Output-Rewrite documentation  | view source Contained in the Output-Rewrite distribution.