Вопрос

I have two arrays that have related data. I need to insert them into a html table. I am accessing these arrays from a different program by using modules which I found out by searching the forum.

package My::Module;
use strict;
use warnings;
use File::Slurp;
use Data::Dumper;
use Exporter;

our @ISA = 'Exporter';
our @EXPORT = qw(\@owners \@values);
our(@owners, @values);
$Data::Dumper::Indent = 1;

my @fileDatas = read_file("/x/home/venganesan/output.txt");

This is under a folder My and is named Module.pm. parts of the other file which will have the table are

use strict;
use warnings;
use CGI;
use My::Module;
my $q = new CGI;

print $q->header;
print $q->start_html(-title=>"Table testing", -style =>{'src'=> '/x/home/venganesan/style.css'});

print $q->h1("Modified WOWO diff");
print $q->table(        {-border=>1, cellpadding=>3},
        $q->Tr($q->th(['WOWODiff', 'Owner', 'Signoff'])),
        foreach $own(@owners){
        $q->Tr(
        $q->td([$own,'Two', 'Three'])},
        $q->td(['four', 'Five', 'Six']),

        ),

I am just trying to print one array to see how it works and then include the other. The output I am getting is both the arrays on command line without the html when I use Module.pm. If i remove it, I get html code. I am learning perl and new modules on the fly. I am open to criticism and better ways to implement the code.

Это было полезно?

Решение

It's 2013. No-one should be generating HTML using CGI.pm these days. By all means, use CGI.pm for generating headers and parsing CGI requests, but please consider using something like the Template Toolkit for your HTML.

I'm not clear what your question is. Are you saying that you get errors if you use My::Module (that's a terrible name for it, by the way)? In that case you should see what gets written to the web server's error log and address the problems given there.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top