Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re (tilly) 1: Indirect Object Syntax Tomfoolery

by tilly (Archbishop)
on Feb 13, 2002 at 13:57 UTC ( [id://145165]=note: print w/replies, xml ) Need Help??


in reply to Indirect Object Syntax Tomfoolery

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:

use strict; my %demo = (foo => "bar", );
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...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://145165]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-23 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found