In Tcl, ohne Erweiterung

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
set fp [open "presidents.txt" r]
set query $argv
 
set query [string trim [string tolower $query]]
set query_list [split $query ""]
set query_glob "*"
foreach item $query_list {
    set query_glob "$query_glob$item*"
}
 
while { ![eof $fp] } {
    set line [gets $fp]
    
    if {$line != ""} {
        if [string match $query_glob [string tolower $line] ] {
            puts $line
        }
    }
}
 
close $fp