in reply to Re: Tutelage, part two
in thread Tutelage, part two

Thank you for the code snippet, and the advice.

I basically just started learning Perl, and I have found that I am of two minds on the use of strict; as a beginner. I now have a script that works, and will get me a good grade - for the beginner's assignment at hand. When I turn on strict; I get several lines of admonishment...yes, very important admomishment, I know...but I also have no output to see if I am even headed in the right direction, and strict; tells me a bunch of new stuff I don't understand on top of it all. I am barely at the point of remembering which part of a hash is the key and which is the value, and I'm just now barely figuring out how $hash{$_}++ does what it does :-D

What I have taken to doing is putting in strict; and then commenting it out until I want to hear from it. As I learn more I know I will want to hear from it all the time, but for now I'm happy that a simple foreach loop even works as written.

Thanks again!

Replies are listed 'Best First'.
Re: Re: Re: Tutelage, part two
by diotalevi (Canon) on Jan 05, 2004 at 04:43 UTC
    Here's the cheat sheet on strict. Declare global variables with our() (or declare them up at the top with 'use vars ...'. and everything other variable with my(). The rest of strict's functions will stop you from writing bugs so if you run into other things then your code is already incorrect.
    use vars ( '$SOME_GLOBAL' ); $SOME_GLOBAL = 42; our $ANOTHER_GLOBAL = 'fnord'; sub a_function { # A variable declared just for the inside of a_function. my $some_param = shift; print "$some_param\n"; }