in reply to How to use cgi table in newindex.pm perl

Have a look at a templating engine like Template::Toolkit, or perhaps HTML::Tiny:

use warnings; use strict; use HTML::Tiny; my $hashref = { 'Adam' => 'Eve', 'Clyde' => 'Bonnie', }; my $h = HTML::Tiny->new; print $h->table( [ $h->tr( [ $h->th( 'Foo', 'Bar' ) ], map( { [ $h->td( $_, $hashref->{$_} ) ] } sort keys %$hashref ) ) ] ); __END__ <table><tr><th>Foo</th><th>Bar</th></tr> <tr><td>Adam</td><td>Eve</td></tr> <tr><td>Clyde</td><td>Bonnie</td></tr> </table>

Replies are listed 'Best First'.
Re^2: How to use cgi table in index.pm perl
by Tabish (Acolyte) on Dec 13, 2017 at 11:11 UTC

    Thank you. but i cant use print in index.pm

      i cant use print in index.pm

      $h->table(...) returns a string, which you can save in a variable and return from a function like your sub getContent.

        I treid but doesnt work for me