in reply to printf function alternative? formatting without printing

If you're dealing with integers,
$array[$i] = abs($n);

If you're dealing with floats,

use POSIX qw( ceil floor ); $array[$i] = int(abs($n)); # Truncates $array[$i] = sprintf('%d', abs($n)); # Rounds $array[$i] = ceil(abs($n)); # Finds ceiling $array[$i] = floor(abs($n)); # Finds floor

Add the "\n" when you print. There's no reason to store it in the array.