Tabish has asked for the wisdom of the Perl Monks concerning the following question:
Hallo to everyone
I treid to make cgi table in my newindex.pm to return data from hashref in a table in my test.pl but cant.
I will appreciate when you give me some ideas or guide me. im new in perl! i also search alot and i know how to use cgi table in "test.pl" but not in "newindex.pm"Here is my code
package newindex; use strict; sub getTitle { return "workers"; } sub getContent { my $cgi = shift; $hashref = { 'Adam' => 'Eve', 'Clyde' => 'Bonnie', }; my $table = ; return $table; } 1;
test.pl
#!"C:\xampp\perl\bin\perl.exe" use strict; use warnings; use CGI qw/:standard/; push @INC, "."; sub getHeaders { my $cgi = shift; return $cgi->header('text/html'); } sub getBody { my $cgi = shift; return $cgi->start_html( getContent($cgi,'title') ) . getContent($cg +i,'content') . $cgi->end_html; } sub getModule { my $cgi = shift; my $action = $cgi->param('action') // 'newindex'; $action = 'newindex' unless (-f $action.'.pm'); eval "use $action;"; return $action; } sub getContent { my ($cgi,$call) = @_; my $module = getModule($cgi); my $caller = 'get'.ucfirst($call); return $module->$caller($cgi); } sub main { my $cgi = new CGI; print getHeaders($cgi) . getBody($cgi); } main();
|
|---|