Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
In case of any error (expecially the errors you don't find easily), print is your friend.
There are three default I/O channels:
  • STDIN (Standard input) where user input at the command line or usually POST - data gets delivered
  • STDOUT (Standard output) is where every print defaults to, the is usually the content send to the browser
  • STDERR (Standard error) for error messages which usually go to an error logfile
  • If you add "debugging prints", which are just prints which help you to understand what your program is doing where and when, first be sure that you'll see them.
    Use your first (running) program and add a line:
    print STDERR "Hello error world\n";
    Now look at the error logfile of your webserver and you should see the line "Hello error world". If you don't see it, your webserver doesn't work like the Apache "default" and we need to redirect the debug messages. Try this as your first script line (after #!/usr/bin/perl or anything else which may be needed to start Perl for this script):
    open STDERR,'>>C:\perl_error.txt';
    Now you should get a file called C:\perl_error.txt with your test debug line. I don't use Perl on Windows myself, so I can't test it myself, you may need to replace the filename by "C:\\perl_error.txt" or "C:/perl_error.txt". Please try it out until you get the debug message.

    Now you are sure that you could read messages from your program. If you had to include a open STDERR - line, copy it to the non-working script.
    Insert ikegami's hint here: Check your error log (where you just got the test debug line "Hello error world") for any open errors for mypage.htm.
    If you don't see any errors, it's a good idea to copy the data to the error logfile in addition to the existing print:

    print STDERR $_;
    You could also add other prints to STDERR to see what your script does and in what order.

    PS: You should look at the CGI module once you start things like HTTP parameter parsing and building complete websites by-script, but it's too complex to start playing around with Perl.

    (For the Perl experts: I know of select and other things which could make some of the above statements wrong, but please remember that this comment is written for a Perl novice who doesn't need to care about such things currently.)


    In reply to Re: Novice trying to find my way by Sewi
    in thread Novice trying to find my way by mortalhero

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post; it's "PerlMonks-approved HTML":



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

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

      No recent polls found