printf "%11s", $_ for (@db); # replace 11 with $db{$_}, the saved width for this column, and # stick a space between columns printf " %$db{$_}s", $_ for (@db);