Hello all. I am still very new to perl, slowly working my way through learning/programming perl which i find are two great books.

But I'm finding it hard to get off the ground with things to code, I have made a few simple apps like calulators and nslookup tools. So I picked up a CGI book as I run a server and thought it would be a good place to start coding something practical.

My question is I made this to start out with and what I don't understand why if all the counter code(within comments) is placed at the bottom the whole page wont display?

#!/usr/bin/perl -w print "Content-type: text/html\n\n"; $code = "index.html"; $counter = "counter.txt"; # countercode open(COUNTER, "< $counter") or die "$_"; $hits = <COUNTER>; close(COUNTER); # countercode open(PAGE, "< $code") or die "$_"; while(<PAGE>) { chomp($_); print "$_\n"; } close(PAGE); print "<CENTER>Hits: $hits</CENTER>"; print "<CENTER>Process ID: $$ Time: $^T</CENTER><BR>"; print "</HTML>"; #countercode open(COUNTER, "> $counter") or die "$_"; $hits++; print COUNTER "$hits"; close(COUNTER); #countercode
So I broke it up and It all comes out fine... also this seems very long winded, if anyone has any comments I would very much like to hear them. Also if anyone has any ideas for good apps/projects to get started with.


In reply to Understanding :: by n00dles

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.