Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert integer to string with leading zeros in Tcl?

Tags:

tcl

I'm learning Tcl. In Perl I can do this:

 $ perl -e 'for ($i = 0; $i < 5; $i++) { printf("name%03d\n", $i) }'
 name000
 name001
 name002
 name003
 name004

Can I do this in Tcl?

like image 734
grokus Avatar asked Nov 05 '09 17:11

grokus


1 Answers

See format:

$ tclsh
% for {set i 0} {$i < 5} {incr i} { puts [format "name%03d" $i] }
name000
name001
name002
name003
name004
like image 118
Sinan Ünür Avatar answered Sep 17 '22 15:09

Sinan Ünür