Well, now all input is checked, but there are caveats about these checks. If some input fields are not given, you'll get warnings for undefined values. Also some Regexps are broken or inefficient. All in all, i'd write it like this:

#!/usr/bin/perl -T use strict; use warnings; use CGI; my $w = new CGI; my $ip = $ENV{REMOTE_ADDR} || 'N/A'; my @errors = (); my $file = time.int rand 1_000_000; my %spec = ( username => qr#^[A-Za-z][-.\w]{2,29}$#, domain => qr#^(a|c|f|h|ho|i|k|o|s|x)\.com$#, email => qr#^[\w\.\-]+\@(?:[a-z\d\-]+\.)+[a-z\d]+$#i, service => qr#^Yes|No$#, conditions => qr#^Yes$#, ); my %fields; foreach( keys %spec ){ my $v = $w->param($_) or do { push @errors => "$_ not defined"; next }; $v =~ $spec{$_} or do { push @errors => "$_ invalid input"; next }; $fields{$_}=$v } print_error( @errors ) if @errors; open LOGFILE,'>>',"var/log/accounts/$file" or die "$file opening failed: $!"; print LOGFILE join(',',@fields{qw/username domain email service/},$ip) +,"\n"; close LOGFILE; print $w->header('text/plain'), "done"; sub print_error { print $w->header('text/plain'), @_; exit; }
--
http://fruiture.de

In reply to Re: Peruse my code... by fruiture
in thread Peruse my code... 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.