Hello,
I am having trouble understanding print staements in CGI.pm
The while loop keeps printing "Content-Type: text/html"
I understand that the default content for print header()is "Content-Type: text/html"
But normally the content type is at the top of the page. Does any one know how to do that?
I can't seem to find any good info on using print with CGI.pm
#!/usr/local/bin/perl -w use strict; use diagnostics; use CGI qw(:standard); ############################# #initialize variable ############################# my $db ="events.txt"; open (FILE, "<" . $db) || die "Well, whats up.. cant open file"; #flock (FILE, 2 ); my $lc = 0; ###################################### # Start of while loop ###################################### while (<FILE>) { my $line = $_; $line =~ s/\n$//; my @events = split ("::", $line); if ($events[1] eq ""){$lc = $line}; ############################## # Print Parish Events ############################## print header(), start_html(-title=>'Script'), "<HR> <table border='0' width='100%'> <tr> <td width='100%'> <table + border='0' width='100%'> + <tr> + <td width='100%'> + <table border='0' width='100%'> + <tr> + <td width='22%'><font SIZE='+1'color='gray' +><B>$events[0] $events[1], $events[2]</B></font></td> + <td width='78%'><font SIZE='+1'color='black +'><B>$events[3]</B></font></td> + </tr> + </table> + </td> + </tr> + <tr> + <td width='100%'><font SIZE='2'>$events[4]</font></td> + </tr> </tabl +e> </td> </tr> </table>", end_html(); ##################################### if ($events[1] eq ""){ #flock (FILE, 8 ); close (FILE); } }

In reply to Printing with CGI.pm by cal

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.