in reply to Re: Monkey patching all subs with a basic 'starting subname' message
in thread Monkey patching all subs with a basic 'starting subname' message

Thanks, Rolf;

'Advice' and 'around' are indeed very good search keywords for examples of what I am doing, and point me right to people who I am sure have done it well -- thanks for this.

prototype is -- now that I have seen it -- obvious, really! Can't believe I missed that on my first scan through perlfunc! I have managed to fold the output of this into my code using eval; of course, now the meat of my redefined sub is essentially a string -- is this the sanest way to apply this?

Replies are listed 'Best First'.
Re^3: Monkey patching all subs with a basic 'starting subname' message
by LanX (Saint) on Jul 14, 2017 at 20:00 UTC
    > of course, now the meat of my redefined sub is essentially a string -- is this the sanest way to apply this?

    Not sure what this "meat" is supposed to mean (?)

    Could you show some code?

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      > Not sure what this "meat" is supposed to mean (?)

      In this case, meat == "majority". As in, what was...

      *$_ = sub { __dbg { "Starting ${package}::${fname}(", join(',', @_), ')' } 4; my @ret = $fn->(@_); };

      ...now becomes...

      *$_ = eval qq{sub $proto { __dbg { "Starting ${package}::${fname}(", join(',', \@_), ')' } 4; my \@ret = \$fn->(\@_); }};

      The eval of an escaped+interpolated string is now just as worrying as the other stuff I was worried about!

      All of which, I'm sure, is the least of my worries!

        > The eval of an escaped+interpolated string is now just as worrying as the other stuff I was worried about!

        I'm sure there are better ways, for instance I'd try to use closure variables.

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!