Posted to tcl by aspect at Tue Jun 19 15:20:29 GMT 2012view pretty

proc case_map {from to input} {
    foreach op {toupper tolower totitle} {
        lappend map [string $op $from] [string $op $to]
    }
    string map $map $input
}

puts [case_map poems poetry "Poems are poems are POEMS (but not pOEMS)"]