Руслан У. Закиров


Regexp::Common::WithActions - adds actions to Regexp::Common


    use Regexp::Common::WithActions;
    my $quoted = $RE{quoted}->action('quote')->(q{a string with ' or "});
    my $dequoted = $RE{quoted}->action('dequote')->(q{'a string with \' or "'});


Some regular expressions from Regexp::Common may be much better with actions to manipulate matched data, for example for all variants delimited provides it's good to have quoter and de-quoter actions.

This module extends %RE with action method. It can be used in the same way as subs or match methods. For example:

    $RE{some}{re}{-with => 'arguments'}->action('action')->('do something');

As you can see action method returns a reference to a function implementing particular action.


Regexp::Common 2.122 has a problem that makes this module less useable. You must load Regexp::Common::WithActions as the last thing (after all other modules that can load R::C) in you programm.

Patch for this issue exists and waiting for abigail to release a new version.


delimited and quoted

'quote' and 'dequote' are two actions provided for these regexps. Both work in place in void context and return new value in other cases.


It's very easy to add a new action for other regexps in the module. Patches are welcome.



Under the same terms as perl itself.