I have a modified script that I would like to write to selected files specified by the html form and I am in need of some direction for I am lost. I was hoping that this would work but alas, it dosen't and I'm not sure why. Please excuse my lack of understanding...I am still learning.

#!/usr/local/bin/perl # Define Variables $basedir = "$ENV{'DOCUMENT_ROOT_OLD'}/www"; $baseurl = "http://www.whatever.com"; $cgi_url = "http://www.whatever.com/cgi-bin/add.pl"; $mesgdir = "messages"; $datafile = "data.txt"; $ext = "html"; $title = "Recipes"; # Done # Get the Data Number &get_number; # Get Form Information &parse_form; # Put items into nice variables &get_variables; # Open the new file and write information to it. &new_file; # Open the Main WWWBoard File to add link &main_page; # Increment Number &increment_num; ############################ # Get Data Number Subroutine sub get_number { open(NUMBER,"$basedir/$catagory/$datafile"); $num = <NUMBER>; close(NUMBER); if ($num == 999999 || $num !~ /^\d+$/) { $num = "1"; } else { $num++; } } ####################### # Parse Form Subroutine sub parse_form { local($name,$value); # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # Remove any NULL characters, Server Side Includes $value =~ s/\0//g; $value =~ s/<!--(.|\n)*-->//g; $value =~ s/<([^>]|\n)*>//g; $FORM{$name} = $value; # Get Variables sub get_variables { if ($FORM{'catagory'}) { $name = "$FORM{'catagory'}"; $name =~ s/"//g; $name =~ s/<//g; $name =~ s/>//g; $name =~ s/\&//g; } if ($FORM{'subject'}) { $subject = "$FORM{'subject'}"; $subject =~ s/\&/\&amp\;/g; $subject =~ s/"/\&quot\;/g; } if ($FORM{'body'}) { $body = "$FORM{'body'}"; $body =~ s/\cM//g; $body =~ s/\n\n/<p>/g; $body =~ s/\n/<br>/g; $body =~ s/&lt;/</g; $body =~ s/&gt;/>/g; $body =~ s/&quot;/"/g; } if ($FORM{'serves'}) { $invoice = "$FORM{'serves'}"; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(t +ime); $month = ($mon + 1); @months = ("January","February","March","April","May","June","July" +,"August","September","October","November","December"); $year += 1900; $long_date = sprintf("%s %02d, %4d at %02d:%02d:%02d",$months[$mon] +,$mday,$year,$hour,$min,$sec); $year %= 100; if ($use_time == 1) { $date = sprintf("%02d:%02d:%02d %02d/%02d/%02d",$hour,$min,$sec, +$month,$mday,$year); } else { $date = sprintf("%02d/%02d/%02d",$month,$mday,$year); } } ##################### # New File Subroutine sub new_file { open(NEWFILE,">$basedir/$catagory/$mesgdir/$num\.$ext") || die $!; print NEWFILE "<html>\n"; print NEWFILE "<head>\n"; print NEWFILE "<title>$subject</title>\n"; print NEWFILE "<STYLE type=text/css>\n"; print NEWFILE ".wrapIt {\n"; print NEWFILE "width:400px;\n"; print NEWFILE "word-wrap:breakword;\n"; print NEWFILE "background-color:white;\n"; print NEWFILE "}\n"; print NEWFILE "</STYLE>\n"; print NEWFILE "</head>\n"; print NEWFILE "<noframes>\n"; print NEWFILE "<body>\n"; print NEWFILE "</noframes>\n"; print NEWFILE "</br>\n"; print NEWFILE " <div align=center CLASS=body><center><table border= +0>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td align=center valign=top colspan=5>\n"; print NEWFILE " <font size=5><strong>$subject</strong></fon +t></td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td align=center valign=top colspan=5>\n"; print NEWFILE " <font size=5><strong>Serves: $serves</stron +g></font></td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " <td>&nbsp;</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td colspan=5>Ingredients:</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td>$labor</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td align=center colspan=5>&nbsp</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td colspan=5>Method:</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; $body = 'OH CRAP' if ! defined $body; print NEWFILE " <td colspan=5 CLASS=wrapIt>$body</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " <tr>\n"; print NEWFILE " <td rowspan=2 colspan=5>&nbsp;</td>\n"; print NEWFILE " </tr>\n"; print NEWFILE " </table>\n"; print NEWFILE " </center></div>\n"; print NEWFILE "</body></html>\n"; close(NEWFILE); } ############################### # Main Page Subroutine sub main_page { open(MAIN,"$basedir/$catagory\.$ext") || die $!; @main = <MAIN>; close(MAIN); } ############################################ # Return html sub return_html { print "Content-type: text/html\n\n"; print "<html><head>\n"; print "<title>$subject</title>\n"; print "</head>\n"; print "<noframes>\n"; print "<body bgcolor=#FFFFFF>\n"; print "<font size=2><b>Entry has been logged, click <a href=\"http: +//wwwdesignaz.netfirms.com/recipes.html\">here</a> to return home.\n" +; print "</b></font>\n"; print "</body></html>\n"; } sub increment_num { open(NUM,">$basedir/$catagory/$datafile") || die $!; print NUM "$num"; close(NUM); }

In reply to Will this work? by saffron

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.