Here is a quicker version of the zero-suppression routine that will also float a leading sign character:
sub ZeroSuppress2($) { my $self = shift; # Return if the argument is less than two digits. return($self) if (length($self) < 2); # Search for a embedded decimal point. my $decimal = rindex($self,'.'); # If the decimal point exists, substract one from its position # to define the end point of the zero-suppression, else determine # the entire length of the string and subtract one to define the # end point of the zero-suppression. if ($decimal > 0) {$decimal-- ;} else {$decimal = length($self) - 1;} # Iterate through the list suppressing leading zeroes. my $i; my $c; for ($i = 0; $i < $decimal; $i++) { $c = substr($self,$i,1); # Skip to the next character if the current character is a # plus-sign, minus-sign, or space. next if ($c eq ' ' or $c eq '+' or $c eq '-'); # Terminate the loop if the current character is s digit. last if ($c > 0); # Replace the zero in the current character with a space. substr($self,$i,1) = ' '; } $c = substr($self,0,1); # Check for a leading sign-character. if ($c eq '+' or $c eq '-') { # If the list has more two elements, move the sign-character # from the leftmost position to the position of the rightmost # space character. if ($i > 1) {substr($self,$i - 1,1) = $c; substr($self,0,1) = ' ';} } return($self); } After running some more benchmarks, this routine is several orders of magnitude faster than sprinf or a regex. Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters 636-922-9158 ext. 652 fax 636-447-4471 [EMAIL PROTECTED] www.nisc.cc _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs