in reply to Re^3: Will this work?
in thread Will this work?
#!/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('/');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Will this work?
by JavaFan (Canon) on May 21, 2010 at 08:59 UTC | |
I think it is copy/paste cargo-cult stuff, that should be replaced by modulesI 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. | [reply] |
|
Re^5: Will this work?
by saffron (Initiate) on May 21, 2010 at 19:17 UTC | |
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.
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. | [reply] [d/l] [select] |
by graff (Chancellor) on May 21, 2010 at 22:04 UTC | |
Well, that's the problem right there. There have been numerous comments about "Matt's Scripts" here at the monastery, including statements like: The last three quotes come from the same thread, which you might want to look at because it also provides a number of very useful resources (although it's now 6 years old). Note that the NMS project mentioned above can be found here: http://nms-cgi.sf.net/ (UPDATE: actually, a better link would be: http://sourceforge.net/projects/nms-cgi/, which shows clear evidence of fairly recent maintenance by our esteemed davorg, among others.) Bottom line: with regard to the code in the OP, the best course of action will be to ditch it and start over, using some better prototype as a starting point. (UPDATE: I think it's worth pointing out that the name "NMS" derives from "Not Matt's Scripts".) | [reply] |
by superfrink (Curate) on May 21, 2010 at 20:58 UTC | |
Learning to write code takes time and practice. Learning to read, understand, and modify someone else's code takes still more time and practice. Learning to write code that is easy for other people to read, understand, and modify takes still more time and practice. Don't quit learning just because something isn't easy. A number of links to suggested reading were posted earlier in this thread. Take a break from this particular problem to learn and practice. Read tutorials. Write small scripts to try the things you read about. Come back to this problem later (say after a few days or a week) and it will appear less complicated. | [reply] |
by graff (Chancellor) on May 22, 2010 at 02:07 UTC | |
How many different users do you expect? Will each user start with their own personal "home" directory for their 27 subdirectories? ( For that matter, does it really make sense for the user to make a deliberate choice about which subdirectory to use for a given submission? Would it make more sense for the directory choice to be "automatic" (e.g. based on some other aspect of the submission)? I didn't see anything (in any of your posts on this thread) that shows the html for the input form itself. How many pieces of input is the user providing when the form is submitted? What else does the user get to do besides submit stuff that will be stored in a file? (For example, what do they do next, after storing something to a file?) In terms of "understanding scriptng", the basic structure of any CGI application goes like this: That's pretty much it. The rest is just structuring the task based on: what you need to present to users, what you expect to get from users, what to do when they don't send you what you expect, and what to do when you can't give them what they need. If that's not enough to help you get a fresh start, I think the best course of action will be to start a fresh thread, with a different question and (if possible) a different initial attempt at perl scripting -- maybe start with some example from NMS or the CGI module manual page -- and maybe some more detail about what you're really trying to accomplish. Oh, I know the CGI man page is huge -- it's a book all by itself -- but you'll be glad when you get familiar with how well it's organized and how useful the examples are. | [reply] [d/l] |