Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

bugs anyone?

by deriwana (Initiate)
on Jun 19, 2001 at 22:29 UTC ( #89765=perlquestion: print w/replies, xml ) Need Help??

deriwana 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'.
(Ovid) Re: bugs anyone?
by Ovid (Cardinal) on Jun 19, 2001 at 22:40 UTC

    Try running your code from the command line. It makes it easy to debug. You are missing a semicolon on line 6:

    my $guest_file = "../new_guestbook.html" # ^ # Insert semicolon here ----------------/

    Also, why are you evaling such a huge chunk of code? I don't see anything in your code that even merits an eval.

    You are also not using strict. If you had, you would have spotted why this is an error:

    seek GUEST, 0,0; # Filehandle should be GUESTS

    If you had used strict, you also would have seen this problem:

    foreach my $guest (@guest) { # Should have been @guests

    The following line has 'or' twice:

    open (GUESTS, "+>> $guest_file") or or die "Can't open $guest_file: $!";

    There are a variety of other issues that guarantee that this script cannot run, but failure to use strict is the biggie. I know it's probably annoying to hear "use strict" over and over, but it will instantly tell you of many of the errors above.

    I really, really tried to get this working, but there were so many other little issues that I finally left it to get back to work. Try developing your code in small, properly formatted chunks. It's much easier to develop that way. It looks like you wrote this all at once with no structure or design. That will bite you every time.

    And did I mention to use strict?

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: bugs anyone?
by mikeB (Friar) on Jun 19, 2001 at 22:44 UTC
    Try adding the line
    use CGI::Carp qw( fatalsToBrowser );
    to your script. It will redirect perl errors to your browser.

    If that doesn't show what's wrong, break your script into smaller pieces and run them. That will help you find the area in question. Then look closely at that section.

    If you still can't find the problem, post the section of code that's causing the problem. Less than a dozen lines should be more than enough to reproduce the problem. You're more likely to get a response if you narrow it down first. In fact, you're quite likely to find it yourself :)

Re: bugs anyone?
by stephen (Priest) on Jun 19, 2001 at 22:56 UTC
    Run your code from the command line with perl -c. This will reveal:
    • You need a semicolon after my $guest_file = "../new_guestbook.html"
    • You need to close your quotes in
      print "Name: <INPUT TYPE=\"text\" NAME=\"new_name\"><BR>\n; print "Email: <INPUT TYPE=\"text\" NAME=\"new_email\"><BR>\n; print "Comments: <INPUT TYPE=\"text\" NAME=\"new_comments\"><BR> +\n;
    • Quite probably many other things. perl -c will reveal them when you run it on this script from the command line.

    Please, please start your script with 'use strict;'. You'll save time, effort, and agony.

    stephen

Re: bugs anyone?
by buckaduck (Chaplain) on Jun 20, 2001 at 00:54 UTC
    I should note that earlier versions of this code have already been analyzed here and here. Interestingly, the program is de-evolving somewhat, having somehow lost the use strict; line.

    Those nodes already have some suggestions for what to do when the server gives an error. In this case, running the program from the command line would have given an enormous amount of feedback.

    The previous responses also gave some clues on how to clean up the code enormously.

    I also note that these questions are still being given horrible top-level node names. Please try to use a title with some meaning. Not "bugs anyone?".

    buckaduck

Re: bugs anyone?
by JojoLinkyBob (Scribe) on Jun 19, 2001 at 22:33 UTC
    Heheh I'll get the easy question out the way first. Do you have the proper permissions set on the perl script? (i.e. chmod +rx?) Desert coder

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2021-08-01 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (7 votes). Check out past polls.

    Notices?