Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Perl TK Submit enter incorrect routine

by minixman (Beadle)
on Nov 15, 2005 at 12:22 UTC ( [id://508579]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl TK Submit enter incorrect routine
in thread Perl TK Submit enter incorrect routine

I am using strict in the program.
in the routines TK i have our which i though't kept the variables non-global and in that routine only.
  • Comment on Re^2: Perl TK Submit enter incorrect routine

Replies are listed 'Best First'.
Re^3: Perl TK Submit enter incorrect routine
by thundergnat (Deacon) on Nov 15, 2005 at 16:33 UTC

    I took a longer look at it and have some more detailed comments/advice.

    In General:

    Use more white space. It's inexpensive and makes debugging less tedious. (Personal opinion, though many will agree.)

    Somewhat related, indent consistantly. Inconsistent, semi-random indentation makes finding missing/extra brackets an excercise in frustration. It also makes following the logic of nested if blocks very tedious.

    Don't declare variables as globals unless necessary, 'our' variables have especially far-reaching scopes and should be avoided if possible. Use 'my' variables instead.

    Keep variables in the smallest scope practical, don't pass Tk widget names to subroutiness if all you want is the widgets' value, pass the value instead. Action-at-a-distance bugs are hard to track down.

    If you are just going to use default values for object attributes, don't include them, it clutters up the code unnecessarily and makes it more difficult for others to help you debug.

    Don't use prototypes for subroutines if you don't need them. And even if you think you do, you probably don't.

    Don't call subroutines with the leading ampersand unless you need the effects it adds. If you don't know what effects it adds, you probably don't need it.

    Something I found puzzling, in the sub process_amend_userorderroute, there are many situations where you are writing information out to a text widget, then, before the information could possibly be displayed, destroying the toplevel that the widget is in. Seems like a lot of wasted effort.

    Anyway, I took the liberty of rewriting some of your code to demonstrate what I am talking about. There are lots of missing subs, so it won't work standalone. It is still more cluttered than I would prefer, but it is a step in the right direction. Take it or leave it as you like.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://508579]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found