Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Table in Perl CGI

by jeffa (Bishop)
on Aug 03, 2015 at 21:24 UTC ( [id://1137300]=note: print w/replies, xml ) Need Help??


in reply to Re: Table in Perl CGI
in thread Table in Perl CGI

Thank you for checking out my module, this really is an honor. :) You can simplify a few things, for what it is worth:

use strict; use warnings; use Spreadsheet::HTML qw( portrait ); my %hash = ( kumquat => 'orange', pomegranate => 'red', cherimoya => 'green', lingonberry => 'purple' ); my @data = ( [sort keys %hash], [map $hash{$_}, sort keys %hash] ); print portrait( data => \@data, indent => ' ', th => { style => { background => $data[1] } }, td => { style => { background => $data[1] } }, ); __DATA__ <table> <tr> <th style="background: green">cherimoya</th> <th style="background: orange">kumquat</th> <th style="background: purple">lingonberry</th> <th style="background: red">pomegranate</th> </tr> <tr> <td style="background: green">green</td> <td style="background: orange">orange</td> <td style="background: purple">purple</td> <td style="background: red">red</td> </tr> </table>

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^3: Table in Perl CGI
by 1nickt (Canon) on Aug 06, 2015 at 20:25 UTC

    It's working nicely ... I wrote the post above after simply testing it out in response to the OP; I'm using it now to build some nightly reports. I particularly like how easy it is to pass attributes to the tag builder. You're right about simplifying, I haven't needed to use a callback at all (but it's nice to know it's built-in for when it's needed).

    The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1137300]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found