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

Hi aitap, Thanks for your reply. I'm interested in trying out O Deparse so I checked out the description o the website. It looks like I can enter my Perl program in there so that they can search it for errors and improve the code. Is that right? If so, I don't see where I input my code... Could you provide some basics on using this website that might help me learn Perl? I'd certainly appreciate it.

Replies are listed 'Best First'.
Re^3: Creating a Hash Syntax Error
by aitap (Curate) on Aug 19, 2014 at 11:41 UTC

    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.

      Thanks, I'll look into these. And, yes, I was saying that sometimes I don't see why I received an error message.