Just a minor alteration...in the return statement you could change the first " to q| and the last to |; to save escaping the other "'s and you could use "x 2" ...eg
if ( $num % 3 ) {
return q|<TD width="200"> </TD>| x 2;
} else {
return q|<TD width="200"> </TD>|;
}
if ( $num % 3 ) {
return q|<TD width="200"> </TD>| x 2;
} else {
return q|<TD width="200"> </TD>|;
}