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...


In reply to Re (tilly) 1: Indirect Object Syntax Tomfoolery by tilly
in thread Indirect Object Syntax Tomfoolery by larryk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.