Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: TK Submenus (Tk::Menu , global variables/ spirit of strict)

by Anonymous Monk
on Oct 29, 2013 at 00:53 UTC ( [id://1060092] : note . print w/replies, xml ) Need Help??


in reply to TK Submenus

Some food for thought :)

Why don't you use Tk::Menu? There is example at widget - Demonstration of Perl/Tk widgets, Menus : 1. Menus and cascades (sub-menus)

Why don't your functions/subroutines take arguments? Why do they work on "global" variables?

Slapping "my $globalvariable" on $globalvariable is not in the spirit of strict, but passing( $variables, $around, is( $in, $thespirit, $of, $strict ) );

 strict itself confers no benefits; The benefits come from avoidance of the bad practices forbidden by  strict :)

Write function, functions that take arguments, functions that return values, functions that don't operate on global variables , but functions that pass variables around
Examples Re: Tk: Creating label in hash

Start reading at Re^2: Border-less main window (Alt+F4 Ctrl+C and follow through to examples Re: Perk Tk - how to send a value from a subroutine back to the main program using Button (without MainLoop), Re: Perl tk FindNext in a text widget, Confused by variable scope in Tk::Wizard

If you're not convinced by what I'm saying read these links