Anyway, as I already said, I prefer monkey-patching over subclassing and you won't need to create another module/namespace for it.
Sub-classing requires that the author played by "the" book, and the OOP book is indeed a TIMTOWTDI library in Perl.
Monkey-patching OTOH is well defined and has no dependency to any OOP model.
So in our own interest consider
sub call_patched { local *Spreadsheet::ParseXLSX::new = \&patched_new; local *Spreadsheet::ParseXLSX::_parse_workbook = \&patched_parse_w +orkbook; # do whatever with Spreadsheet::ParseXLSX }
And all patches will disappear outside this function.
For completeness: Both ways may fail if there are any lexical variables closed over the patched subs, but even this can be solved with PadWalker, iff this really happens.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re^3: Help to override Spreadsheet/ParseXLSX.pm module (monkey-patching)
by LanX
in thread Help to override Spreadsheet/ParseXLSX.pm module
by boleary
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |