Hi Martin, thanks for your kind words.
On Sat, 28 Feb 2015 09:01:26 -0600 "Martin G. McCormick" <mar...@server1.shellworld.net> wrote: > Shlomi Fish writes: > http://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top > > > > (Note: perl-begin.org is a domain I originated and maintain). > > Shlomi Fish, Uri and Brock, > > I certainly wish I had known about a resource like this > earlier in my relatively short perl career. Thanks for the compliment. Note that that page is heavily inspired by the book https://en.wikipedia.org/wiki/Perl_Best_Practices by Damian Conway. So you should extend your thanks to him as well. > > One can find limitless samples of good and bad perl code > on the internet and from textbooks but programming languages > really shine when one knows why or at least somewhat knows why > the coding is done in a certain way which usually boils down to > making it easier to comprehend by someone else or making it > easier or even possible for the compiler or interpreter to > process. > > I knew I could probably cobble together something that > fixed the problem I was asking about but the way the code I > wrote failed told me that I didn't understand all I thought I > knew. > > I actually thought pre-declaring the variables was a > good thing since I had been doing that in C and various > assemblers for 35 years if you count all the way back to when I > got in to computing by accident after going to college to do > something totally different. Ah, I'm not sure pre-declaration is still recommended in C++, as well as C99 and later versions where variables can be declared and initialised in the middle of a block. > > I expect the large code I have written will now work > after applying the following quote from your site: > > > However, this is bad form in Perl, and the preferable way is to declare > > all the variables when they are first used, and at the innermost scope > > where they should retain their value. This will allow to keep track of > > them better. > > Again, thanks for creating this great resource. I hope I can > stop reading it long enough to fix the problem at hand. You're welcome. If you'd like to help me a little as gratitude, please see these pages about it: * http://perl-begin.org/contribute/ * http://www.shlomifish.org/meta/how-to-help/ * http://www.shlomifish.org/meta/donate/ (*NOTE*: www.shlomifish.org is my personal web site.) > > My last day of work before retirement is Monday, March 2 > but I will just be starting something new at the age of 63 > rather than going away. :-). Also see http://www.shlomifish.org/humour/fortunes/show.cgi?id=quora-learning-to-drum-at-65 . Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Best Introductory Programming Language - http://shlom.in/intro-lang To have bugs is human; to fix them — divine. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/