Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

perlman.pl only works in the debugger under cygwin

by diamond (Acolyte)
on Feb 27, 2009 at 15:41 UTC ( [id://746915]=perlquestion: print w/replies, xml ) Need Help??

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

The book Advanced Perl Programming by Sriram Srinivasan contains a perl script to display the content of man pages in a TK window. When attempting to run the script under the current cygwin, using its version of perl, TK, X, etc. I get a stack dump:
$ perlman.pl Scouting man directories Starting UI ...Tk::Error: Can't set -activebackground to `undef' for T +k::Menu=HASH(0x103a7ad0): Cannot use undef value for object of type ' +border' at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Configure.p +m line 46. at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 294 Tk callback for . Tk callback for .frame Tk::Derived::configure at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin +/Tk/Derived.pm line 306 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Wid +get.pm line 205 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/T +k/Widget.pm line 256 Tk::Menubutton::menu at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/T +k/Menubutton.pm line 348 Tk::Menubutton::separator at /usr/lib/perl5/vendor_perl/5.10/i686-cyg +win/Tk/Menubutton.pm line 358 main::create_ui at script/perlman.pl line 105 Can't set -activebackground to `undef' for Tk::Menu=HASH(0x103a7ad0): +Cannot use undef value for object of type 'border' at /usr/lib/perl5/ +vendor_perl/5.10/i686-cygwin/Tk/Configure.pm line 46. at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 294 at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 306
However, when invoked through the debugger the script runs just fine:
$ perl -d perlman.pl Loading DB routines from perl5db.pl version 1.3 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(perlman.pl:8): print STDERR "Scouting man directories\n"; DB<1> c Scouting man directories Starting UI ...Done
...after which the Perlman window appears.

Any ideas?

Replies are listed 'Best First'.
Re: perlman.pl only works in the debugger under cygwin
by Anonymous Monk on Feb 27, 2009 at 16:03 UTC
      Thanks for the reply. I was actually wondering why the perlman.pl script only works when being debugged rather than looking for a suggestion for an alternate, perl-based, GUI man page viewer.
Re: perlman.pl only works in the debugger under cygwin
by webfiend (Vicar) on Feb 27, 2009 at 18:03 UTC

    This looks like some fairly crusty old code. You probably are better off with the suggestion of using something else. Nevertheless, I am curious. Do you get any information running this script with warnings enabled?

      There is only one warning:
      "my" variable $section masks earlier declaration in same scope at perl +man.pl line 179. Scouting man directories Starting UI ...Use of uninitialized value $id in hash element at /usr/ +lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/After.pm line 39.
      etc.

      Removing the second my declaration does not change the result (nor should it, looking at the code).

      I am puzzled as to how the debugger "fixes" the code. The implication from error messages is that an undefined value is being used where it is not permitted; how can the debugger fix that? In fact, it shouldn't. The reason I even tried the script in the debugger was to see where the problem was and to try to fix it.

Re: perlman.pl only works in the debugger under cygwin
by JadeNB (Chaplain) on Mar 01, 2009 at 02:24 UTC
    It seems to be the create_ui call that's failing, and the only variable there that isn't set explicitly (like $match_type and $ignore_case) or wrapped (like '-label' => "($section_name)" on line 153) is the $section_name in the arrayref passed to command on line 154. Could you add some diagnostics before and after to see if it's this call that's the problem? (I'm a little suspicious of that call anyway, since the author seems to think that a my $var; for $var (@array) {} declaration makes sense, whereas in fact the my $var has no effect on the for code—not even shadowing any external occurrence of $var. (Also, I don't see where the hash %sections is initialised.))
Re: perlman.pl only works in the debugger under cygwin
by lamprecht (Friar) on Mar 01, 2009 at 15:21 UTC
    Hi,

    I don't have Tk under cygwin to test, but what happens if you override your default activebackground like so:

    line90 ++

    sub create_ui { my $top = MainWindow->new(); $top->optionAdd('*activeBackground' => 'red');# or sth. # MENU STUFF
    Regards, Christoph

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://746915]
Approved by Bloodnok
Front-paged by Sinistral
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-25 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found