in reply to How to PRINT CGI html table to a PNG file

I'm just going to show you how to use CGI;

In your program you do "use CGI" but then you don't actually use it! By using ':standard' it gives you an easy way to type HTML that is much cleaner than HTML so it's easy to understand and edit. Here are your 2 exact programs using all the juicy CGI shortcuts for HTML.

home.cgi:

#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard center/; my $date = localtime; print header.start_html(-bgcolor=>'#c0e0f9').br. center( h1('Home'). h3($date). img({src=>'root_partition.cgi' }).br.br.br. img({src=>'var_partition.cgi' }).br.br.br. img({src=>'stacked_Bar_graph.cgi' }).br.br.br. img({src=>'topsenders_hbar.cgi' }).br.br.br. img({src=>'toprecipients_hbar.cgi'}).br.br.br ).end_html;
Sys_Load.cgi:
#!/usr/bin/perl use strict; use warnings; use CGI ':standard'; use Sys::Load qw/getload uptime/; my ($one_m, $five_m, $fifteen_m) = (getload())[0,1,2]; print header.start_html(-bgcolor=>'#c0e0f9'). table({-style=>'width:20%'},caption('Load Average'), Tr( th({-bgcolor=>'#FFDD00',-height=>'25'},'1 Minute' ). th({-bgcolor=>'#FFDD00',-height=>'25'},'5 Minutes' ). th({-bgcolor=>'#FFDD00',-height=>'25'},'15 Minutes') ), Tr({-style=>'font-family:veranda',-bgcolor=>'#FFFFFF'}, td($one_m), td($five_m), td($fifteen_m) ) ).end_html;
CGI is awesome. Enjoy!

Replies are listed 'Best First'.
Re^2: How to PRINT CGI html table to a PNG file
by hippo (Archbishop) on Aug 22, 2018 at 08:07 UTC

    It would also only be fair to theravadamonk to point out that the documentation for that very module says, "HTML Generation functions should no longer be used".

      CGI is a core module on millions of computers. Apple ships Perl 5.18.2/CGI with macOS on brand-new Macs as one example. There are countless nodes on Perlmonks recommending and teaching CGI. Just because some newbie hijacked Perl's most popular and useful module does not mean you weirdos who troll every CGI node don't look ridiculous. CGI.pm represents 17 years of development by a huge number of people and trying to throw it away is disrespectful nonsense.

      This is not a video game.
      CGI is not the bad guy.
      Even though you get points here for killing him.

      Points! And an imaginary cup of coffee...

        There are countless nodes on Perlmonks recommending and teaching CGI.

        I recommend CGI. Sometimes I even recommend CGI.pm. I don't recommend using the HTML generation fuctions of CGI.pm. Those are 3 different things.

        Perhaps you'd care to read some of my fervent defences of CGI on this site before labelling me one of the "weirdos who troll every CGI node". You will receive no further feeding from me today in any case.

        I'm a 20-year CGI vet here to say you're right, CGI is not the badguy. You are. Your attitude is toxic and it makes your salient points indigestible. And using center() in HTML code? Why not add your myspace link to your sig so everyone knows when your skills ossified?