http://qs321.pair.com?node_id=682073


in reply to Re^3: Format, empty vars, and fixed-width records
in thread Format, empty vars, and fixed-width records

You could handle number overflow like Excel does:

sub format_num { my $s = sprintf('%5.2f', $_[0]); return length($s) > 5 ? 'XXXXX' : $s; }