*Update: I do not need it to be uploaded to a server, only temporarily interpreted, and the resulting variables stored in variables need to be printed on screen (dont know if that makes a difference)

Hello everyone, I am sorry if I am asking something that can be pieced together from the forums, but i have searched google and forums for a few hours now, and cant get this code to work. *all of these codes work fine by them selves, but assembling them seems to be a problem.

What i am trying to do is make a simple form, have an upload box for a file which contains data. This file is then processed via perl script, and then the results need to print out in the browser.

I have managed to create a basic form and know it is passing things to the perl script, but for some reason after that, i can print statements BEFORE ANY of the "processing", but after, none of the printing shows in the browser.

Also, all of the lines which print in the terminal, do not print in the html page. I am really lost and any help would be appreciated, below is the code for the 3 files.

Thank you for any assistance you can provide

concepts.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <title>Form Example</title> </head> <body> <!-- Insert your content here --> <form action="cgi-bin/concepts2.pl" method="post"> <p>File:<input type="FILE" name="file"> <input type="submit" name="submit" value="Submit"> </form> </body> </html>
concepts2.pl #!/usr/bin/perl use strict; use CGI; my $cgi=new CGI; print $cgi->header(); print $cgi->start_html(-title=>'Form Results', -author=>'BoChak'); #my $file=$cgi->param('file'); my $file="/root/Desktop/test.fasta"; print "<br> $file <br>"; ################ Process File ######################### #my $file=<>; my $seqname=''; my $sequence=''; my %seqhash=(); open (FILE,"<$file") or die "Can't open $file\n"; while (my $line=<FILE>){ chomp($line); if ($line=~m/^>/){ my @temp=split(' ',$line); $seqname=substr($temp[0],1); } elsif ($line=~m/^\s$/||$line=~m/^$/){ $seqhash{$seqname}=$sequence; } else { $sequence=$sequence.$line; } } close (FILE); ######################################################## foreach my $key (keys %seqhash){ my $risk=docParser->new($key, $seqhash{$key} ); $risk->CAG_count(); } print $cgi->end_html."\n";
docParser.pm package docParser; use strict; sub new { my $class = shift; my $self = bless {}, $class; my $seqname=shift; my $sequence=shift; $self->{_seqname}=$seqname; $self->{_sequence}=$sequence; return $self; } sub CAG_count { my ($self)=shift; my $seqname=$self->{_seqname}; my $sequence=$self->{_sequence}; my $count_of_CAG=0; my @seq=split(//,$sequence); my $aa=''; my @position; my $len; my $amino_acid_number; for (my $index=0; $index<$#seq-2; $index+=3) { if ($sequence=~m/((CAG){6,})/g){ $count_of_CAG++; @position=index($sequence,$1); $len=length($1)/3; $amino_acid_number=shift(@position); } } print "For the sequence ".$seqname." we found a CAG string "; print "with $len\n repeats "; print "at amino acid number ".$amino_acid_number."\n\n"; if ($len<35) { print "Risk Evaluation: Normal"."\n\n"; } elsif ($len>36||$len<48) { print "Risk Evaluation: Warning"."\n\n"; } elsif ($len>48) { print "Risk Evaluation: Dangerous"."\n\n"; } } 1;

In reply to Passing a file from a form, processing, and then outputting as html by bobekdj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.