Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

debug the error!!!

by Anonymous Monk
on Jun 09, 2000 at 21:40 UTC ( [id://17376]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: debug the error!!!
by Ovid (Cardinal) on Jun 09, 2000 at 22:30 UTC
    You could try using the Perl debugger on this one. From the command line, type
    perl -d PROGRAM
    This starts your program with the Perl interactive debugger. Since your problem is at line 185, set a breakpoint at it once you are in the debugger.
    b 185
    Then 'c'ontinue the program and it will run until the breakpoint.
    c
    The next line of code you will see is line 185. Note: the debugger displays the line of code about to be executed. Then, print the value the suspect variable(s) that name be causing the problem.
    p $variable1, " ", $variable2, " ", $variable3
    The spaces are to prevent the vars from being run together.

    Make sure you print them both before and after the code is run to see how they've changed. Particularly, print the value of any variables upon which a conditional depends.

    At this point, step through the problem area one line at a time to check it's execution.

    s
    After stepping through each line, print out the value of the variables you wish to examine to see if anything is different from what you expect.
RE: debug the error!!!
by turnstep (Parson) on Jun 10, 2000 at 02:08 UTC

    Here's a problem (not the only problem, but probably the one you were looking for):

    $/="astat.gz";$k=0 ## About line 84

    Hrmmm...what is that doing there? $/ is the "Input Record Separator" and 9 times out of 10, the only thing you want to do to it is to undefine it (or set it to null). Basically, instead of separating any files read in after this by newlines, it separates it by the string "astat.gz" This is your problem - since the string "astat.gz" was not found in the file, it was read in a one long line. Quick fix: don't mess with $/.

      Thanks A lot!!! after reading the third reply I could successfully debug the error... Earlier comments really didn't help as I had already tried all of themm Thanks a lot!!!! bye!!
Re: debug the error!!!
by swiftone (Curate) on Jun 09, 2000 at 21:45 UTC
    I've put all sorts of general comments on the code below. I can't find your specific error, but following these style tips should help you find it yourself, or be more likely to get help in the future.
    #!/usr/local/bin/perl
    Use perl -w to turn warnings on. Include "use strict;" to enforce variable declaration. See perlstyle for tips.

    $hour=<STDIN>;chop($hour);
    There is no real reason to use chop()...get in the habit of using chomp(), and use chop() only when you really mean it.

    #goto LABELEND;
    I realize this has been commented out, but you should not have to use goto. A case can be made for when to use goto, but given perl's great flexibility in flow-control, you can plan to never use it and be fairly safe.

    if (open(NAMEONED,$onedname))
    You should always report error conditions on file opens. Try : open(NAMEONED, $onedname) or die "Can't open $onedname: $!";

    #use PGPLOT; # Load PGPLOT module #print "\nTesting simple point plot...\n\n"; #print "PGPLOT module version $PGPLOT::VERSION\n\n";
    When posting code and asking for help, remove all useless, commented out lines.

    $k++;goto NEXTLINE;
    This is somewhere where a goto is unnecessary. Look up line labels, next and last in perlman:perlsyn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://17376]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-16 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found