in reply to Critique my First Script for me?

You're using the CGI OO interface, so why use CGI qw/:standard/;?
//////* Open up your copy of CGI.pm, and take a look at :standard
':html2'=>['h1'..'h6',qw/p br hr ol ul li dl dt dd menu code v +ar strong em tt u i b blockquote pre img a address cite samp dfn htm +l head base body Link nextid title meta kbd start_html end_htm +l input Select option comment charset escapeHTML/], ':html3'=>[qw/div table caption th td TR Tr sup Sub strike app +let Param embed basefont style span layer ilayer font frameset fr +ame script small big/], ':form'=>[qw/textfield textarea filefield password_field hidde +n checkbox checkbox_group submit reset defaults radio_group popup_menu button auto +Escape scrolling_list image_button start_form end_form startfor +m endform start_multipart_form end_multipart_form isindex tmpFileN +ame uploadInfo URL_ENCODED MULTIPART/], ':cgi'=>[qw/param upload path_info path_translated url self_ur +l script_name cookie Dump raw_cookie request_method query_string Accept user_agent +remote_host content_type remote_addr referer server_name server_software server_po +rt server_protocol virtual_host remote_ident auth_type http save_parameters restore_parameters param_fetch remote_user user_name header redirect import_names put Delete Delete_all url_param cgi_error/], ':standard' => [qw/:html2 :html3 :form :cgi/],
That's a lot isn't it, and you're only using param (wasteful). You should either use CGI qw/param/; (not reccommended), or change your map hash builder to use $q->param(... instead of just param(... (also not reccommended). Or, and this is reccomended, just call Vars like i mention below (ala my %FORM = $q->Vars();. *////////

You should also turn on taint ( #!perl -wT...)
* look for the cgi security stuff in perlfaq or search the site for taint checking (or visit Ovids homenode) for more info

What do you think $words = <TEXTFILE>; accomplishes? That will get a single line out the handle, is that what you want?

What's this?

print "Content-type: text/html\n\n"; print "<HTML> \n"; print "<body bgcolor=000000 text=99CCCC> \n";
You got CGI, use it (print $q->header(),$q->start_html()....).

open (TEXTFILE,"$path_to_text") || die "where's the damn file? : $!" is pretty good, but || die "where's the hell is $path_to_text? : $!" is better.

It is also a good idea, to use CGI 2.73; #version, cause you never know.

Also, the way you build you %FORM is clever, but CGI (modern versions, not ancient), have a Vars method that will do that for you, and considerably (%50+) quicker (cause it doesn't call param a million times).

* - updates made

 
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void

perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Replies are listed 'Best First'.
Re: (crazyinsomniac) Re: Critique my First Script for me?
by jerrygarciuh (Curate) on Sep 22, 2001 at 02:05 UTC
    The %FORM was contributed by Ovid during my search engine research, the use CGI qw/:standard/; is left over from that, I thought it was invoking CGI.
    I will make a point of rereading some of my CGI books now that my code knowledge is growing, I was reading them first when I found I needed to learn Perl to make any sense of them.

    I don't understand several of your questions and this will make them excellent points on which I may build knowledge. Thanks again crazyinsomniac!
      the use CGI qw/:standard/; is left over from that, I thought it was invoking CGI.

      use CGI; is all you need if you are using the OO interface (that's when you do my $q = CGI->new;). The 'qw/:standard/' part imports function names so that you don't need the $q variable and lets you, e.g., say 'param($field)' instead of '$q->param($field)', which makes it a little more of a hassle, but I don't like to import anything I don't have to, and sometimes you might need to create more than one CGI object, and so in that case the OO way is the only way to go.

        sometimes you might need to create more than one CGI object

        I like and use the OO interface too, and I've heard the above statement before... Have you ever actually needed to create more than one CGI object? I don't believe I've *ever* seen anything like:

        my $q1 = CGI->new; my $q2 = CGI->new;
        Have you?

        -Blake

Re: (crazyinsomniac) Re: Critique my First Script for me?
by jerrygarciuh (Curate) on Sep 23, 2001 at 22:00 UTC
    CI, About using use CGI qw/:standard/; while using CGI OO interface: When I don't use it the bit Ovid gave me won't work:
    my %FORM = map { $_, @{[ param($_) ]} > 1 ? [ param($_) ] : param($_) } param();
    presumably because it is written in the function-oriented style (?correct?). I have been reading perlman:lib:CGI and I am attempting to get my head around how the line does its thing. Maybe I will attempt an OO rewrite of it soon.
    Peace.
    jg