Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Just another Perl shrine

Re: debug the error!!

by turnstep (Parson)
on Jun 20, 2000 at 15:34 UTC ( #18975=note: print w/ replies, xml ) Need Help??

in reply to debug the error!!

The short answer is that you have a bunch of syntax errors, simple things like closing parenthesis, misplaced quotes, etc. In particular, line 123

is missing the closing parenthesis. Also, at line 251:
does not have a semi-colon at the end - this is what was causing the start of the errors you reported.

This is (at least) the second time you have posted to this site without properly formatting the code. Expect your post to be voted down heavily. There are still many other errors in your post after the two mentioned above. (A hint: check for balanced parens). I could write A LOT about the problems in your code, but you would do yourself a large favor by following a few guidelines:

  • Develop a consistent coding format, especially in regards to indenting. Indent two lines (or whatever you like, just be consistent) at the start of every block (i.e. after an opening '{' ) and add or remove indentation at the start and end of every block. This will really help to catch your syntax errors.
    $example="this_is"; if ($start_a_block) { print "Indent by two spaces\n"; print "And keep indenting until the blopck is done\n"; } for $x (@every_block) { print "Indenting goes in 2 spaces every time\n"; if ($another block) { print "Notice we are now inside two blocks, "; print "and have indented twice\n"; } print "Still inside the 'for' loop, so indent is 2\n"; }
  • Use a good editor (such as emacs (which is available on Windows as well!)) that can help you to balance parenthesis and curly braces automatically.
  • Look at other people's code (on this site, or, even better in a book like Learning Perl or Effective Perl Programming) which can show you a "better" way to do things. That way, you can learn why the following example lines, which still compile and are technically correct, could all be written better
    $hour=<STDIN>;chop($hour); for($n=0;$n<=10;$n++) {chop($calibnamenew);} for($c3=0;$c3<=$c2;$c3=$c3++)
    Since I listed them, I suppose it's only fair to show the better way as well:
    chop($hour=<STDIN>); for $n (0..10) { chop($calibnamenew); for ($c3=0; $c3<=$c2; $c3++) {
  • Don't use perl monks to help you solve syntax problems: try really hard to figure those out yourselves. I understand that your previous two problems might have been a little tricky to track down, but there are things you can do (besides wrapping your code in CODE tags) that will make it easier for us to track down the bug. Try commenting out parts of the code to narrow down the error. Try doing the same thing other ways and in other places. If the line reporting the problems looks correct (as it was in this case) start going backwards line by line, looking for simple things like a missing quote or a misplaced semi-colon.
  • Don't give up! That is a rather large program that you are attempting. It looks like you have a C background - train yourself to think in perl, not C (your 'for' loops gave you away) Clean up and format your code. When it runs without errors, run it with a -w. Then add 'use strict' to let perl *really* start digging for problems. Have patience and debug carefully. Study other people's scripts. Learn about the many ways of doing it. Eventually you will develop your own style. Study the online perldocs, especially in regards to the functions. Often times they include not just a description of what the function does, but good examples as well. Don't worry about getting flames on the site. Your post was badly formatted, but at least you asked a perl-related question, which is more than we can say about some of the posts here. :)

Comment on Re: debug the error!!
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://18975]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2014-03-15 01:12 GMT
Find Nodes?
    Voting Booth?

    Have you used a cryptocurrency?

    Results (314 votes), past polls