I am creating a webserver where I am using a tool called HMMer. When user uses this server they have the option to generate the output for the input either as tabular output or as text output.My problem is to show both output in the web page. I am doing the coding in Perl.

I have used the PERL coding like:






     if ( -z 'Data/testtblop' ) 
                      print "File is empty and has no alignment\n"; //Sometimes FIle may be empty also......
                  else
                  open( FILE, '< Data/testtblop.out' ) or die "Can't open $filename :$!";//File is tabular output
                //This html code is for tabulr output
                <html>
                    <body>
                        <p>
                            <pre> read(FILE1, $text,$filesize)   </pre>
                        </p>
                    </body>
                </html>              
                if ( -z 'Data/testop' )                          //File is simple text format
                    print "File is emptyand has no alignment\n";
                else
                    open( FILE1, '< Data/testop' ) or die "Can't open $filename :$!";
                my $filesize= -s "testop.out";
                //This html code is for tabulr output
                <html>
                    <body>
                        <p>
                            read(FILE1, $text,$filesize) 
                        </p>
                    </body>
                </html>Inline Code Example Here    
                    close FILE1;
                    close FILE2;







        Pl correct me if I am wrong.............

Pl help...............

Dani AI

Generated

Brief diagnosis and direction (notes for ): the script must print an HTTP header first, use lexical filehandles and three-arg open, and escape any file content before embedding it in HTML. is right that tabular output should be emitted as a proper <table>; the key is parsing the HMMer tab output into columns before printing. Common bugs in the original post: mismatched filenames/paths, mixing HTML outside print statements, using C-style // comments (Perl uses #), and using read() in a way that never gets printed.

Minimal, safe workflow

  • Add use strict; use warnings; and print the header: Content-type: text/html; charset=UTF-8\n\n.
  • Check file existence/size with -s or -e.
  • For plain text results: slurp the file, HTML-escape it, and wrap in <pre>.
  • For tabular results: read line-by-line, split into columns (tab or whitespace), HTML-escape each cell, and emit <tr><td>...</td></tr>.
  • Use three-arg open and lexical handles: open my $fh, '<', $path or die ....

Example patterns (short, original)

use strict;
use warnings;
use CGI qw(escapeHTML);

print "Content-type: text/html; charset=UTF-8\n\n";

my $text_path = "Data/testop";
if (-s $text_path) {
    open my $fh, '<', $text_path or die "open: $!";
    local $/;
    my $body = <$fh>;
    close $fh;
    print "<pre>", escapeHTML($body), "</pre>\n";
} else {
    print "<p>No text results</p>\n";
}
my $table_path = "Data/testtblop.out";
if (-s $table_path) {
    open my $fh, '<', $table_path or die "open: $!";
    print "<table>\n";
    while (my $line = <$fh>) {
        chomp $line;
        my @cols = split /\t/, $line;   # or /\s+/ if space-delimited
        print "<tr>";
        for my $c (@cols) { print "<td>", escapeHTML($c), "</td>" }
        print "</tr>\n";
    }
    print "</table>\n";
    close $fh;
} else {
    print "<p>No table results</p>\n";
}

Troubleshooting tips: verify exact file paths and webserver permissions, add warn statements during development, and stream large outputs instead of slurping. For production consider Template::Toolkit or a PSGI framework (Plack/Mojolicious) to separate HTML from logic.

What is format of file how data is placed

You have to user rows and columns with <table> <tr> <td> table tags

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.