"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The main problem isn't finding $mod, it's getting it to work, and you've done that. Congratulations! However, there are a couple of things you might find it useful to change. Firstly, "use strict" at the top of your script. Always. Until you know enough to ignore that advice. Secondly, try having a short main body of code calling a couple of top-level functions:
It makes it easy to see what the script does at a glance, and lets you re-use bits more easily. Thirdly, make sure you scope your variables. Use "my" to restrict them to their defining block. Otherwise, the $n in calcMagic for example is the same as the $n at the top of your script. If you changed it inside the sub it would change in the main script too.
Finally, read up on Getopt::Long (http://search.cpan.org/~jv/Getopt-Long-2.38/lib/Getopt/Long.pm). That will let you call add named options to your script so you can do something like: draw_star.pl --points=5 --radius=200It's a well-known and well tested module, and has good documentation. You could also replace the multiple "if" statements with a lookup into an array, but I'm not sure it would make the code any clearer really. Hope that's helpful. In reply to Re: RFC: Creating unicursal stars
by huxtonr
|
|