R. Joseph Newton wrote:
Cy Kurtz wrote:


Hi all. I have a little program here that generates a lottery play slip
for the mega-millions game. It selects 50 of the 52 numbers exactly once
over 10 tickets of 5 numbers each. It then selects 10 super ball
numbers, one for each ticket. It then prints it all out(duh).

I wonder if anyone would like to poke fun at my code. I'm kinda new at
this so I'm sure there's a lot done wrong. For starters, the 'use
strict;' and 'use warnings;' lines do not like my code at all(not sure
why)


Then you should find uncomment them and find out why.  One thing to bear in
mind--the Perl compiler, and the strict and warnings pragmas used by it, are
only software.  They do not have the capacity for anthropomorphic sentiments,
such as liking or disliking.

I know that floods of warnings can be frustrating.  What I do when my code
generates such a flood is to use a break [Ctl-C on Windows] to stop execution
right after the warnings start.  Then I look at the  first error or warning
message. learn what it means, and correct the situation causing it.  Then I run
again.  I may still have errors and warnings.  So again, I look at and deal with
the first one:

while (my $first_message = shift @errors_or_warnings) {
   learn_meaning($first_message);
   correct_error($first_message);
   run_or_compile_script();
}

I am sorry if this doesn't seem helpful.  One thing you can do, if you are truly
at a loss trying to understand what is behind an error, is to post the error
message, the code surrounding the line inidcated in the message [with that line
marked], and any declarations or assignment statements affecting variables
involved in the indicated line, to this list.  We then will have something solid
on which to base our suggestions.

It looks like James has gone the extra mile for you here, so I would suggest
that you read through his responses, and make sure that you understand the
issues that he is pointing out.


Good words from Joseph, I will add that until you become familar with the warnings themselves you may want to consider the 'diagnostics' pragma,


use diagnostics;
perldoc diagnostics

It extends the aptly named 'terse' diagnostic messages.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to