in reply to Regular Expression from Hell

You aren't anchoring, that's what's wrong with the regex. But you shouldn't use a regex in the first place.
printf "<td height=20 class=grtxt>%05d</td>\n" => $test;
will do fine.

Abigail