# change this: print $_, ' 'x($data[$i]->{w}-1-length); # to this: print $_, ' 'x($data[$i]->{w}-1-length(expand($_)));