PreshBlog

HTML::Table::FromDatabase 1.00 released with row_callbacks feature

by on May.24, 2011, under Perl, Programming

I just released version 1.00 of HTML::Table::FromDatabase, with a new row_callbacks feature.

You could already declare callbacks on a cell-level basis, so you could say, format monetary values appropriately, round numeric columns, turn URLs into clickable links etc. Now, you can also declare a callback which receives an entire row as a hashref, which it can modify as needed.

An (admittedly somewhat contrived) example from the documentation:

my $table = HTML::Table::FromDatabase->new(
    -sth => $sth,
    -row_callbacks => [
        sub {
            my $row = shift;                                                                                 
            if ($row->{name} eq 'Bob') {
                # Hide this row
                $row = undef;
            } elsif ($row->{name} eq 'John') {
                # John likes to be called Jean these days:
                $row->{name} = 'Jean';
            }
        },   
    ],       
);

I decided to bump the version to 1.00 for the sake of anyone who considers 0.x versions to be unready for production use; this module has been about since 2008 and is working well in production use for me.


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!