Hey all-

So, I'm working on Regexp::Func, a module designed to do function-based
regex manipulation. This is based on Perl 6 RFC 164; it's designed as a
proof-of-concept and Perl 5 module to test its usefulness.

The module provides three methods:

     m//    =>  match "//", $strings ...
     s///   =>  replace "///", $strings ...
     tr///  =>  trade "///", $strings...

The goal is to provide a functional interface to Perl RE's for those
situations when it's easier than the =~ binding mode (See
http://dev.perl.org/rfc/164.pod for some examples).

The problem is that I don't know of a way to get rid of the "" around
the // in the functions above. I'd like to be able to say:

    $new = replace /(\w+)=(\S+)/$1:$2/, $old;

But this doesn't work for a variety of reasons. So, I played around with
this syntax:

     replace qr/from/, "to", $string;

Since the right hand of a s/// is just a double-quoted string, but that
didn't really work satisfactorily (I couldn't get the qr// to integrate
back in with s///, but it could be I don't know what I'm doing).

Right now, the internals of the module are simplistic - little more than
eval() wrappers around the built-in Perl RE stuff w/ some wantarray()
return things thrown in there. It actually works pretty well for its
simplicity.

I'm willing to expend some more energy if I can get it to work "right";
that is, not having to say:

     $new = trade '/a-z/A-Z/', $old;

But if it's gonna take tons of time I'll probably just leave as-is.

Any input? Is there something about prototypes or qr// I'm overlooking
that could fix this?

Thanks,
Nate

Reply via email to