in reply to Re: Will this work?
in thread Will this work?

I've had a look through his code, and aside from his html templates, his code is not worth salvaging.

No amount of describing the symptoms is going to help.

It doesn't compile, its incomplete, there is massive scope/variable confusion, and there is hand-rolled CGI/date code that has been haunting perl since at least 1997 :)

He does try to sanitize his inputs, but with all that scope confusion, there is no telling what directory he is trying to write to.

I started fixing up his program, but I honestly believe he'll benefit more from studying the basics first.

Replies are listed 'Best First'.
Re^3: Will this work?
by JavaFan (Canon) on May 21, 2010 at 08:19 UTC
    My bet is that his CGI code isn't hand rolled. It's likely to be copied and pasted. His date code might as well.
      I may have been misusing the phrase hand-rolled, I think it is copy/paste cargo-cult stuff, that should be replaced by modules, ie
      #!/usr/local/bin/perl -T -- use strict; use warnings; use CGI(); use Time::Piece qw[ localtime gmtime ]; my $cgi = CGI->new; my $subject = $cgi->escapeHTML( $cgi->param('subject') ); my $time = localtime; my $long_date = $time->strftime; my $date = $time->hms .' '. $time->mdy('/');
        I think it is copy/paste cargo-cult stuff, that should be replaced by modules
        I wouldn't phrase it that way. It doesn't matter if you copy and paste bad code, or if you use a module with said code. Use good code, that's the important thing.
        What I am trying to accomplish is to restructure the code to write data gathered from an html form to a user selected directory from the same form...

        $catagory

        this is selected by the user so if the user wanted to select catagory x, then data would only be sent to directory x, or if catagory y was selected, then data would be sent to directory y.

        # Define Variables $basedir = "$ENV{'DOCUMENT_ROOT_OLD'}/www/myfile"; $baseurl = "http://www.whatever.com/myfile"; $cgi_url = "http://www.whatever.com/cgi-bin/perl.pl"; $mesgdir = "messages"; $datafile = "data.txt"; $mesgfile = "myfile.html"; $ext = "html"; $title = "My File"; # Done

        This only sends data to the specified location...only one directory, I was hoping that I could some how change it to write to a user selected directory(1 out of 27 directories) The original code was from a friend who modified Matt Wright's WWWboard code a little to have seperate output from being clumped together. I thought if that was possible, I could modify it further by sending data to a selected directory by the user. If no one can help me, then please say so, but if someone can help, then let me know what I can do. I have some books on perl and cgi but they are dated 97 or eairler and I can't seem to wrap my head around them. Please forgive me, I am frustrated and cannot seem to understand scripting, let alone learn it or even afford to have someone to write it for me. Maybe I shouldn't even be here since I have no understanding of scripting.