in reply to Re^2: Creating a Hash Syntax Error
in thread Creating a Hash Syntax Error

I'm not sure of I understand you correctly. AFAIK, http://perldoc.perl.org is not capable of checking Perl core for errors. But you can do it on your machine:

  1. Run perl -c yourfile.pl. Perl will compile your program and check for mistakes which can be found without running most of it.
  2. If if gave you an error message which you can't understand, try use diagnostics; (or add -Mdiagnostics command line switch) or ask splain program for help.
  3. If you still don't understand why Perl doesn't like some particular line (e.g. it happens on a completely valid line, empty line, or end-of-file), or the program works incorrectly without throwing errors, maybe your understanding of the program differs from Perl's at some earlier point. Run perl -MO=Deparse,-p yourfile.pl (which has the effect of temporaly adding use O 'Deparse', '-p'; to the file) and check if Perl understands you correctly. Additional '-p' option enables additional parentheses which cause incorrect program behaviour often.
  4. Indenting your programs now helps to understand them later. Your computer can indent a Perl program for you using perltidy.
  5. Everything works, but you are not sure whether you did something right? perlcritic will thoroughly search your code for common mistakes and suggest best practices.
See also: basic debugging checklist.

Replies are listed 'Best First'.
Re^4: Creating a Hash Syntax Error
by ms238 (Initiate) on Aug 20, 2014 at 01:18 UTC
    Thanks, I'll look into these. And, yes, I was saying that sometimes I don't see why I received an error message.