go ahead... be a heretic | |
PerlMonks |
Re^3: Help to override Spreadsheet/ParseXLSX.pm moduleby bliako (Monsignor) |
on Apr 03, 2021 at 19:43 UTC ( [id://11130784]=note: print w/replies, xml ) | Need Help?? |
I guess this is the hybrid "monkeyclassing"! Was package ParseXLSX; at the 1st line of both original and patched files? If yes then you define a class (package) and then you redefine that class in the 2nd CE_ file. I have no idea what's meant to happen in this case. Obviously it did work for you and in your circumstances but I do not know how robust this is. For example, reversing the order of use statements would have different effect. Here is a tiny example of subclassing in Perl. You subclass class P1 by creating a new class in a new file P2.pm . Consider this:
The above demonstrates how P2 inherits all methods from P1 and then overwrites A1() but all other still hold as they were defined in P1. How does that translate to your case? P1 is the original class/package. And P2.pm is the new file and package you created essentially overwriting 2 methods. The caveat here is that ALL your scripts which mention use P1; now should be modified to use P2;. Well OK, unless you don't have this power. bw, bliako
In Section
Seekers of Perl Wisdom
|
|