Posted to tcl by schelte at Sat Aug 18 20:57:15 GMT 2012view pretty

proc main {} {
    for {set i 0} {$i < 256} {incr i} {
        lappend hex [format %02x\n $i]
    }
    set fp [open "testdata" rb]
    while {![eof $fp]} {
        set out ""
        binary scan [read $fp 30000] cu* bytes
        foreach n $bytes {
            append out [lindex $hex $n]
        }
        puts -nonewline $out
    }
    close $fp
}

main