I have spent a lot of time recently reading about writing PERL scripts.
Despite having written numerous scripts over the last few years, it appears that the book I learnt
from has taught me some poor programming techniques. Not using STRICT was the main
one but there are numerous others. I am in the process of writing, what is for me, a large script
and thought I'd better clarify a few procedural points before I launch into the main writing phase.
My script is a web site which interacts with a MySQL database.
My questions are regarding the flow of the script.
I have always structured this type of script using a menu system where each section of the web
site calls a menu item and after vars have been set, a subroutine is called to perform whatever
calculations and display functions are required. Since starting to use the STRICT pragma, my vars
have become unwieldy beasts and need to be brought under control.
Where should these vars be declared? At the start of each call? One way would be to declare all
the vars at the start of the script but that would be too much overhead for the server.
All the tutorials I have read show how to declare vars using MY, OUR etc. but only in the context
of a single function. I need some guidance on var declaration within a more complex script.
Keith
Despite having written numerous scripts over the last few years, it appears that the book I learnt
from has taught me some poor programming techniques. Not using STRICT was the main
one but there are numerous others. I am in the process of writing, what is for me, a large script
and thought I'd better clarify a few procedural points before I launch into the main writing phase.
My script is a web site which interacts with a MySQL database.
My questions are regarding the flow of the script.
I have always structured this type of script using a menu system where each section of the web
site calls a menu item and after vars have been set, a subroutine is called to perform whatever
calculations and display functions are required. Since starting to use the STRICT pragma, my vars
have become unwieldy beasts and need to be brought under control.
Where should these vars be declared? At the start of each call? One way would be to declare all
the vars at the start of the script but that would be too much overhead for the server.
All the tutorials I have read show how to declare vars using MY, OUR etc. but only in the context
of a single function. I need some guidance on var declaration within a more complex script.
Keith