Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

getting module output in a cgi file

by rjsaulakh (Beadle)
on Dec 17, 2005 at 11:35 UTC ( #517468=perlquestion: print w/replies, xml ) Need Help??
rjsaulakh has asked for the wisdom of the Perl Monks concerning the following question:

how do i get the o/p of this module insdie a cgi file i want to display the hyperlinks to the pages

sub pageNumbers { $total_pages = int (($#matches) / $total_records_page); #Integer +division $remainder = ($#matches) % $total_records_page; if ($remainder) { $total_pages++; } if($total_pages) { print <<"END"; <table cellpadding="0" cellspacing="0" bor +der="0" width="100%"> <tr> <td class="smtxt"> END print "<b>Page&nbsp;</b>"; for $i (1 .. $total_pages) { if ($i == $page) { print "<b>$i</b>"; } else { print "<a href=\"winner.cgi?page=$i&period=$period\">$ +i</a>"; } if ($i != $total_pages) { print "&nbsp;|&nbsp;"; } } print "<!-- '$total_pages' '$remainder' --></td></tr></table>\ +n"; } } exit(0);

Replies are listed 'Best First'.
Re: getting module o/p in a cgi file
by bradcathey (Prior) on Dec 17, 2005 at 13:18 UTC

    Like the good monks have been telling you, use a templating system like HTML::Template and a lot of your issues will dissolve away. Get the HTML out of your CGI. It's sooooo much easier.

    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: getting module output in a cgi file
by Joost (Canon) on Dec 17, 2005 at 15:59 UTC
    Remove the exit statement or you won't even be able to use the module. also, I'd STRONGLY suggest using strict, lexical variables and pass the values as function arguments instead of relying on vars that are declared (or not) SOMEWHERE else.

    then do something like:

    use ModuleName; # ... pageNumbers($total_pages,$matches,$total_records_page, @and_whatever_o +ther_variables_you_need);
Re: getting module output in a cgi file
by Your Mother (Bishop) on Dec 17, 2005 at 19:43 UTC

    Don't forget that using abbreviations like "o/p" can be confusing to readers who aren't sure what they mean especially in this case when I believe you actually meant G.O. (Kidding!)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://517468]
Approved by Joost
[Discipulus]: the same for me! I'd use your own one! ;=)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-05-28 10:06 GMT
Find Nodes?
    Voting Booth?