Using: Perl v5.10.1, MySQL 5.5.15, DBI.
I need to deliver end users output from a database via email. They do not want this as an attachment, but in the body.
I’d like to deliver the data in an ascii table and am having issues determining if DBI has built in functions to do this (output similar to querying MySQL from the command line).
Or If I can determine the longest row character length I can use that to build the table. I have a way to get the max item length in an array, but I can’t wrap my head around doing it with the query results.
my $spacer_length = (reverse sort { $a <=> $b } map { length($_) } @array)[0];
Assuming a generic DBI loop, you could do something like this:
Using the “defined-or” operator
//to avoid anundefwarning and possible contamination in case of negative values.