I've inherited an application that issues several different SQL requests,
lovingly creating different lists of user-friendly column names for each of
the different database column names that might be returned. To cut down
future maintenance requirements, I thought I would generalise the
HTML-emitting code to read the column names from
The following hash is intended to help render database column names into
more user-friendly column names for the resulting HTML <table>. Some
user-friendly names are two words, some only one.
my %sname = qw {
COUNTRY_NAME Country
...
};
my %words2 = (
"ORDER_NUMBER", "Order Number",
...
);
#%sname{keys %words2} = values %words2;
%sname = (%sname, %words2);
I couldn't find a way to combine the whole assignment into any fewer
statements, apart from the obvious way of double-quoting everything in
sight, on the model of %words2. Moreover, the commented line was lifted
straight out of the Llama book 2nd Ed p70, and gave a syntax error - the
line below it works, but is described there as "much slower" than the
commented line.
Any offers to improve the foregoing, other than what I've called "the
obvious way"?
Rgds, GStC.