RosettaCodeData/Task/Flow-control-structures/Tcl/flow-control-structures-6.tcl
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

8 lines
289 B
Tcl

proc forfilelines {linevar filename code} {
upvar $linevar line ; # connect local variable line to caller's variable
set filechan [open $filename]
while {[gets $filechan line] != -1} {
uplevel 1 $code ; # Run supplied code in caller's scope
}
close $filechan
}