New in Tcl? Coming from another language? Read on. This could be fun. I learned almost all of my programming with [PHP], and a little bit of [Perl]. This sheet [http://www.cs.tufts.edu/g/20/notes/php_perl.php] helped me an awful lot when I tried to learn [Perl], so a Tcl cheat sheet may be awfully useful to someone else. Feel free to add other languages. ---- '''PHP:''' file.php3 '''PERL:''' file.cgi '''TCL:''' file.tcl ---- '''PHP:''' scripts in '''PERL:''' whole file is script '''TCL:''' whole file is script ---- '''PHP:''' can include raw HTML '''PERL:''' must print all output '''TCL:''' must print all output ---- '''PHP:''' no requirements for first line '''PERL:''' first line is #!/local/bin/perl (but is that a requirement?) '''TCL:''' first line can be #!/local/bin/tclsh (but that is no requirement) ---- '''protections''' '''PHP:''' not executable file '''PERL:''' executable file '''TCL:''' What the heck? You can make almost any file executable in nix platforms! ---- '''PHP:''' chmod 644 file.php3 '''PERL:''' chmod 755 file.cgi '''TCL:''' er... I don't know ---- '''printing''' '''PHP:''' echo "stuff\n"; '''PERL:''' print "stuff\n"; '''TCL:''' puts stuff '''OR''' puts "some stuff" '''OR''' puts {some stuff} ---- '''variables''' '''PHP:''' All variables $var '''PERL:''' $var is a scalar variable. '''TCL:''' '''var''' or '''$var''' - more detailed explanation needed here. See [set] ---- '''PHP:''' $var always means one thing '''PERL:''' $var, @var, %var, var are different things! '''TCL:''' $var and var always means one thing (???) ---- '''arrays''' '''PHP:''' $var = array(1,2,3); '''PERL:''' @var = (1,2,3); '''TCL:''' well, there are lists... set var "1 2 3" '''OR''' set var [[ list 1 2 3 ]] and arrays... array set var "key1 value1 key2 value2 key3 value3" '''PHP:''' "numeric" arrays and "associative" arrays '''PERL:''' "arrays" and "hashes" '''TCL:''' "lists" and "arrays" ---- '''PHP:''' $var[[1]] is second element of $var '''PERL:''' $var[[1]] is second element of @var '''TCL:''' [[ lindex $var 1 ]] is second element of $var ---- '''PHP:''' count($var) is length '''PERL:''' scalar(@var) is length '''TCL:''' [[ llength $var ]] is length ---- '''PHP:''' for ($i=0; $i"ho","hi"=>4); '''PERL:''' %var = (1=>"ho","hi"=>4); '''TCL:''' array set var "1 ho hi 4" ---- '''PHP:''' $var[['ho']] is element indexed by 'ho' '''PERL:''' $var{'ho'} is element of %var '''TCL:''' $var[['ho']] is element indexed by 'ho' '''confusing???''' ---- '''PHP:''' while (list($k,$v) = each $var)) {...} '''PERL:''' while (($k,$v) = each %var) {...} '''TCL:''' er... foreach { key value } [[ array get var ]] {...} ---- '''to be continued...''' ---- [Category ???]