srebecchi <[EMAIL PROTECTED]> wrote: : : I am working with a couple of program that were in a SAMS : 24 hour book. They create html forms that are used to : enter data and then save the input to a text file. Another : displays a list of the created files for selection and : viewing using html href links. : : The first program generates a data entry form and, on : submit.. creates a text file with standard headers or : labels for each field. : Although the SAMS book talks about converting the program : to be used to edit the text file, it does not explain how : to do it. : : I've been able to create a program that displays an html : form listing all the text files that have been created and : the url/path to each file. : : I need help with two things... : 1) modify the data entry form to read in the text file it : created .. so it can be edited and saved back under the : same name.
It isn't impossible to modify the existing form, but I'd begin with a whole new form and fill it with the fields from the file. Basically, the "value" of each field would have to be set to the text extracted from the file. : 2) find out how to call the program from a html (href) : command line that will open a selected file. I think it : would be something like... : (a href="http:/www.mysite/cgi-perl/editform.cgi -???- : myfile.txt) The ??? is what I'm looking for. If you are using the same program to edit that you used to create the file and if that script does not use a field called "edit_file", you could use this URL: /cgi-perl/editform.cgi?edit_file=myfile.txt You can retrieve the parameter using this: use CGI; my $q = CGI->new(); my $file = $q->param( 'edit_file' ); You will probably need to add some path information to $file. (The example above uses the object-oriented interface to CGI.pm.) : Here is a sample of a text file it creates: The data entry : form program outputs the field names that label the data : in the program and in the text file. : : <DATE_FILED>Wed Mar 17 15:29:01 2004</DATE_FIELD> Is it supposed to be <DATE_FILED> and </DATE_FILED> or <DATE_FIELD> and </DATE_FIELD>. You could use like it is above, but it would be better if the opening tag matched the closing tag. : <STORY_TITLE>This is the third story for march 17</STORY_TITLE> : <BYLINE>Bill</BYLINE> : <BODY> : And I would like to see how the lines wrap now that I have : eight image files : in the works : <BR> : </BODY> : : Any and all suggestions would be greatly appreciated. You need to read up on regular expressions and on parsing files. This is a poor format. Writing the file in an XML format would allow you to use an XML parser module to extract the information and might allow easier information sharing down the line. An RDF schema would probably be useful here. I think the example in the book was meant to illustrate how files and forms are processed. This is not an excellent starting place for a full featured story editor. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>