The following is my first script created using the Llama and the help of the Monks hereabouts to whom I am very grateful. I have added vars for the bits most likely to change or which are repeated and made modifications based on all responses to my posts. I would like to ask for a critique of my programming so that I may know where I have used bad form, insufficient commenting, insecure methods, or shown insuffucient laziness etc.
The script is meant to check a password and, if correct, write form input to a text file which is used as an SSI. I want to learn to make dummy-friendly interfaces for clients to update the most frequently changed parts of their websites. It will become more elaborate as I try to make it edit a table calendar. That said here is the script.
TIA
jg

#!/usr/bin/perl -w use strict; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser /; my $q = CGI->new(); #declare some vars my $mail ='menu@uranus.com'; my $path_to_text="/home/mysite/www/myfolder/my.txt" # Parse Form Search Information # if it's a single form value, map the value as a scalar, otherwise, t +he value is # an arrayref my %FORM = map { $_, @{[ param($_) ]} > 1 ? [ param($_) ] : param($_) } param(); my $words = $q->param('words'); if ($words eq ""){ $words = "no specials today"; } my $user = $ENV{'REMOTE_ADDR'}; my $pass = $q->param('pass'); if ($pass ne "whatever"){ open (TEXTFILE,"$path_to_text") || die "where's the damn file? + : $!"; $words = <TEXTFILE>; close (TEXTFILE) || die "close damn you : $!"; print "Content-type: text/html\n\n"; print "<HTML> \n"; print "<body bgcolor=000000 text=99CCCC> \n"; print "<CENTER><H1><font face=Arial>!Unauthorized Access!\n"; print "<BR>"; print "The menu for tonight remains \n"; print "<font color = blue> $words </font>"; print ". <BR> \n"; print "<font color = red>Hey bub, stop messin' with my menu!\n +"; print "<BR>You are at IP address $user !"; print "</H1></CENTER></font></body>"; open MAIL,"|mail $mail" or die "mail problem : $!"; print MAIL "$user tried to get in using $pass for a password.\ +n"; close MAIL; exit 0; }else{ open (TEXTFILE,"$path_to_text") || die "where's the damn file? : $ +!"; print TEXTFILE $words; close (TEXTFILE) || die "close damn you : $!"; print "Content-type: text/html\n\n"; print "<HTML><body bgcolor=000000 text=99CCCC><CENTER><H1> <font f +ace=Arial> \n"; print "The menu has been updated for you. <BR> \n"; print "The menu for tonight is \n"; print "<font color = blue> $words </font>.</CENTER></H1></font></b +ody>"; open MAIL,"|mail $mail" or die "mail problem : $!"; print MAIL "$user changed the menu $words.\n"; close MAIL; }

In reply to Critique my First Script for me? by jerrygarciuh

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.