joybee2015 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I copied DialogBox.pm and Wm.pm to my local directory and modified a little bit in dialog->"add" , wm->"popup" subroutines. And I used the line "perl -Mlib=localdirctorypath myperl.pl" to run myperl script. It didn't seem to use the local subroutines. In myperl.pl I have line "Use Tk::Dialogbox".

Can anyone tell me what I should do to make it work?

Thanks a lot!

Replies are listed 'Best First'.
Re: How to override the standard module
by Corion (Patriarch) on Oct 01, 2015 at 19:53 UTC

    While your approach is weird and likely bad, you will still need to copy these files to a directory localdirctorypath/Tk/Dialogbox/. Personally, I would at least use require to load the files or better, use one of the documented mechanisms to subclass the Wm and/or the DialogBox.

Re: How to override the standard module ( Monkeypatch Tk megawidget)
by Anonymous Monk on Oct 01, 2015 at 21:54 UTC

    In one program, as a proof of concept, monkeypatch

    use Tk; use Tk::DialogBox; use Tk::Wm; ## overrides sub Tk::Wm::Pancake { ... } sub Tk::DialogBox::Syrup { ... }

    If it works, and you want to share with other programs, subclass, see Tk::mega and ?node_id=3989;BIT=Construct%20Tk%3A%3AWidget;HIT=tk

    package Tk::JoyDialogBox; use Tk::widgets qw/ DialogBox /; use base qw/ Tk::DialogBox /; Construct Tk::Widget 'JoyDialogBox'; sub Pancake { ... } sub Syrup { ... }