#!/usr/bin/tclsh8.0 set string1 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" set string2 "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm" while {[gets stdin line] >= 0} { set newline "" for {set num 0} {$num < [string length $line]} {incr num 1} { set char [string index $line $num] set idx [string first $char $string1] if {$idx >= 0} { append newline [string index $string2 $idx] } else { append newline $char } } puts stdout $newline }