I think what you are trying to do is imminently accomplishable with Perl if you are putting the interface on the web. With that being said, would you be sending this program to others or would they access a website to find the information? I don't how to write standalone Perl applications but if you are running a website, then you can test your scripts either by the command line as suggested or download the appropriate flavor of the free Apache web server (http://www.apache.org) to your computer. I have a WinXP myself and have both Perl and Apache locally but also am a relative newbie, but here's my stab at the possible code anyway for my own learning experience and I hope this helps somewhat. Remember too that you need to learn how to secure your CGI programs -- someone else needs to help with that. Anyone with criticism of this partial pseudoCode?
=PseudoCODE #shebangLine, warnings and taint turned on
use CGI; # use the CGI.pm module installed with current versions of Perl library: some CGI.pm help (http://stein.cshl.org/~lstein/)
use CGI::Carp 'fatalsToBrowser';
use strict;
my $query = new CGI;
my $filename = $query -> param('nameOfInputFieldWithFileName'); #if you give the name of the files in your html
my $geneticCodeToSearchFor = $query -> param('geneticCodeToSearchForFromFormInputField');
print "Content-type: text/html \n\n";
unless (param) #type in your conditional or if you want all input fields filled out use code as is
{
#BEGIN HTML
print <<"PrintHTML";
<html>
<head>
<title>Search the Files</title>
</head>
<body>
<form method="post" action="cgi-bin/nameOfThisCGIScript">
<input type="text" size="50" name="nameOfInputFieldWithFileName">
<input type="text" size="100" name="geneticCodeToSearchForFromFormInputField">
<input type="submit" value="Submit">
<input type="reset" value="Clear Form">
</form>
</body>
</html>
PrintHTML
#END HTML, you can use anything with print statement like "EOF"
#but it has to be spelled exactly the same (case matters) at the print statement and at the end of your html tags
#In this case, PrintHTML has to be on it's own line, by itself with only a carriage return
}
else
{
print <<"PrintHTML";
<html>
<head><title>Alert!</title></head>
<body><h1>All form fields must be filled out.</h1>
<p>Please fill out the form <a href="nameOfThisCGIScript">Click Here</a></p>
</body>
</html>
PrintHTML
exit(0);
}
my @filepath = qw/ filepathToDirectory1 filepathToDirectory2 filepathToDirectory3/;
my $filesInDirectory = 0;
my $match = 'no';
#CODE for searching directories for $file
#Loop through @filepath array, increment $filesInDirectory until reach end of @filepath array
#CODE to open $filepath[$filesInDirectory]
#Create hash with $filepath[$filesInDirectory]
# if ($filepath[$filesInDirectory] =~ /$filename/ig) #if you gave file name options
#if you didn't give filename options, loop through the hash then open, slurp, close each file
#CODE for opening $file, slurping $file, closing $file
#CODE for searching contents of $file
if (geneticCodeInFile =~ /$geneticCodeToSearchFor/ig)
$match = 'yes';
print "<html><title>Genetic Code Found</title>";
print "<body><p>$filename</p></body></html>";
else {$match = 'no'}
if ($match = 'no") { print <<"PrintHTML"; # type your html tags and messages here <a href="nameOfThisCGIScript">Search Again</a> # rest of html tags PrintHTML } =PseudoCODE
At 10:35 PM 3/4/2004, you wrote:
> : I have an application that runs in batch mode and generates 5 output > : files for every input file (all are flat text, and each of the 5 is > : in a different directory). > : I would like to build a simple browser-based UI that provides links > : to each output file, so they can be opened and examined efficiently > : at the end of a run, without forcing the user to navigate through > : directories and search through output files from other runs. In > : addition, I would like to include links to the most recent output > : file of each type, in the event that the user wants to review the > : results from an old run and then link to the most recent output. > : (Sorry if that's not clear ...) I know how to collect the filenames > : I need - my problem is with the display. > > You mention above that you have some web programming experience. > What are you experienced in?
I'm a biologist by training. My programming experience is mostly with perl (data mining and parsing), although I worked briefly with C and VB a few years ago. I've got a bit of experience with HTML (very basic) and posting/retrieving data to/from web servers (LWP), but only what I've learned by necessity.
> : Since I'm trying to generate dynamic HTML pages, I thought CGI would > : be the way to go. However, from what I understand of CGI, it > : requires a web server and can't be run locally. > > Since CGI is an interface between a program on a server and a > browser it would by definition need a server. Many perl CGI programs > can be tested from the command line. I tested my perl programs from > the command line for about a year before I installed a local copy of > Apache.
I was hoping I could use the local computer as the 'server', and use CGI (or something else) as a method of highly targeted directory/file navigation.
> : Any ideas on how to do something like this are appreciated. > : If this idea of a UI is ludicrous, I'm open to others! > > You may be able to install a web server on your local computer. > You haven't mentioned the intended platform. Tell us what that > OS is and what OS is no your local box and we can help point you in > the right direction.
I would really like to keep the number of dependencies to a minimum, so users don't need to install a lot of other software and try to configure everything. My app is intended to be standalone, with perl (and a few non-core modules from CPAN) as the only requirements.
I would guess the majority of my target user group (biologists) will be using Winxx, although I'm sure there will be the occasional *nix user also. I work on a Windows XP machine, but I also have a boot option to linux that I use occasionally.
To clarify my description above, I was envisioning a navigation system with a layout similar to the ActiveState perl docs (two frames, with the TOC in the left frame and the actual docs in the right frame). In my case, the list of genes that were analyzed in a given run would appear on the left, and selecting (clicking on) a gene would produce a list of the output files from that analysis in the right frame. The output filenames would in turn link to the actual output file. In addition to the files produced in a given run, I'd like to add links to the most recent output files produced, regardless of run (the files can be created asynchronously, since different parts of the program can be run independently). Since the most recent filenames will change over time, creating a static HTML file for each gene after each run won't work. Hence, my thoughts of using CGI (or similar) to query the output files that are available in each directory and create the pages on the fly.
I'm sure someone else can come up with a better method than the one I described. Thanks for all your help.
Bob
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>