in reply to use of strict
Use my:
my ($w, $str, $line); $w = 3; $str = "abc"; $line = sprintf ("%${w}s ", $str); [download]