Thanks, I hope this can help.
#!/usr/local/bin/perl use CGI qw/:all/; $| = 1; my $q = new CGI; my $action = $q->param('action'); # Read in all the variables set by the form CGI::ReadParse(*input); # Print out a content-type for HTTP/1.0 compatibility print "Content-type: text/html\n\n"; $month = $input{'month'}; $date = $input{'date'}; $year = $input{'year'}; #$action = param('action'); #print $action; $numberoflines = &CountCurrentRecords('events.txt'); if($action eq "add_data"){ print "Your post was sucessful<br>"; #check_event(); add_data(); } else{ #print "We are not in the Add sub-routine<BR>"; #this is just an example fictitious default subroutine } if($action eq "preview"){ #print "<BR>Is this information correct?<br>"; preview(); } else{ #print "We are not in the Preview sub-routine<br>"; #this is just an example fictitious default subroutine } ############### BEGIN COUNTCURRENTRECORDS SUBROUTINE ################# +####### sub CountCurrentRecords { $number = 1; my($database) = ($_[0]); open(DATABASE, "$database"); while ($line=<DATABASE>) { $number++; } $number = 0 if $number < 0; close(DATABASE); return $number; } ###################################################################### +####### ## ## Preview Data Section ## ###################################################################### +###### ############### sub preview ######## sub preview{ print "<html> <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>$month +$date, $year</B></font></td> <td width='78%'><font SIZE='+1'color='black'><B>$input +{'title'}</B></font></td> </tr> </table> </td> </tr> <tr> <td width='100%'><font SIZE='2'>$input{'message'}</font></td +> </tr> </table> </td> </tr> </table> <BR> <form action method='post'> <input type='hidden' name='action' value='add_data'> <input type='submit' value=' Publish new event '> <BR><INPUT type='button' value=' Continue Editing ' onClick='histo +ry.go(-1)'> </form> <BR> $numberoflines </html>\n"; } ###################################################################### +####### ## ## Add Data Section ## ###################################################################### +###### ############### sub add_data ######## sub add_data{ # Print out a content-type for HTTP/1.0 compatibility $addfile = "events.txt"; print "$month"; print $month; #print "We are in the add_data sub-routine<BR>\n"; # Open the file for appending open (OUT, ">>$addfile") or die "Can't open $addfile\n"; $number = $numberoflines; $message = $input{'message'}; $line = join '::', $number,$month,$date,$year,$title,$message; print OUT "$line\n"; close OUT; }

In reply to Re: Re: problem with variable by cal
in thread problem with variable 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.