Wisdom is sought from the monks for a beginner. I have installed various cgi/perl packages but I have decided to write what I thought would be a relatively easy script - oh how naive for one so old! I am trying to determine output based on the month, the codse I have been working with is as follows:-
#!/usr/bin/perl #$myname="Merlin"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (tim +e + ($timediff * 3600)); @months = ('01','02','03','04','05','06','07','08','09','10','11', +'12'); $month = $months[$mon]; print "Content-type: text/html\n\n"; if ($month==11){ undef $/; open (FILE, 'hours.txt'); print <FILE>; close FILE; }
If i exclude the if statement and the relevant { or } the script displays the contents of hours.txt but as soon as I use the if statement the 500 Internal Server Error is displayed.

I have searched the monastary and from the examples I have found I thought I had got the syntax correct. Perhaps I have looked at this for too long and can't see the obvious errors. Hopefully someone can spot my problem and offer a solution and set me on the path to enlightenment.

Many thanks for any help that may be offered

Julian

Edit by castaway, fixed closing code tag, added some p tags.


In reply to If/else problems by Anonymous Monk

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.