Do you know where your variables are? | |
PerlMonks |
Re: Overridding subroutines called in private subroutinesby blazar (Canon) |
on Oct 21, 2008 at 10:13 UTC ( [id://718440]=note: print w/replies, xml ) | Need Help?? |
I'm attempting to override the, "absUrl" method, which isn't really a method at all - but just a subroutine in the module itself. (First of all, apologies for replying so late!) So, why are you saying it's a method at all? (If it's not called like a method, then it's not a method...) Apart that in Perl 5 methods and subroutines are exactly the same thing, but for how they are called... The only weirdness I can find in this module is that the absUrl subroutine is only called in MIME::Lite::HTML itself in private subroutines of the, "parse" method, like this: Nope: in Perl 5 there's no notion of private subs to other methods/subs. Of course there's nothing strictly wrong declaring and defining it there, but it would be just as if it where declared outside of the body of the surrounding sub. Except for having access to some lexical variables of the latter: but remember that it won't close over them! To do so, you can use an anonymous sub and assign it to a lexical, which gets as close as possible to the concept of a "private sub" IMO.
I'm not sure if I understand what you mean. If it compiles, then it's valid Perl. However, since nobody has pointed it out thus far, the comma is not a valid character in prototypes and if you use warnings perl will duly warn you:
Without warnings, I presume that the comma is silently ignored. I was trying to use B::Concise to check whether that's actually the case, but I don't really know how it works, and appearently it ignores prototypes at all, nor does it even mention it in the docs, as a quick check revealed. All I can do is to naively run the following tests:
--
In Section
Seekers of Perl Wisdom
|
|