Syntactic Confectionery Delight | |
PerlMonks |
Re (tilly) 1: Indirect Object Syntax Tomfooleryby tilly (Archbishop) |
on Feb 13, 2002 at 13:57 UTC ( [id://145165]=note: print w/replies, xml ) | Need Help?? |
First of all your approach won't work since if Perl already
knows about a function, it won't think that is meant to be
a method call. (Perl already knows about its internal
functions.) An approach with more chance of success is to try to override the core function as described in perlsub. But on experiment that doesn't seem to work. A major problem with your approach is that even if you can get substr to work, the RE engine assumes that it knows all about the low-level string representation, and uses that knowledge directly. I don't think you will easily be able to get native REs to transparently cross line boundaries. And this problem is not simple, Perl has at least one bug related to that. The following code will work in an eval, but not in a file, for exactly this reason: However all is not (yet) lost. Open source encourages code reuse. Usually you reuse wisely. Sometimes that means that you might just take the module, copy it, and then edit it to do what you want. Should you be able to find a way to do this configurably, then submit the patch back. If you don't, then you at least can get your job done. (The last time I used this approach was to create a version of LWP::Protocol::http.pm that showed me the communication between LWP and the webserver...) If you can't figure out how to do that edit, well you may be out of luck this time, but you probably just learned something useful about how overriding does(n't) work, and likely also learned from the source-code. Knowledge isn't always the reward you want, but getting it isn't a bad consolation prize...
In Section
Seekers of Perl Wisdom
|
|