Hi I have the following scenario. I read in a file line by line; then each like will look like: 2 0, 3 0, 4 0, 9 0, 11 3 etc; like "string string". each like then will be put is a variable; $line will have one set of value in each iteration within while loop; now I want to be able to catch if a line is repeated or similar to one we saw previously..
myFile will contain:
2 0 3 0 9 0 11 3 3 5 2 9 2 0 3 5
Here is the code:
set in [open myFile r]
set exline ""
while {[gets $in line] >= 0} {
lappend exline $line
if { [lsearch $exline $line] > 0} {
puts "same number repeated $line"
}
}
close $in
How about:
set fid [open myFile]
while {[gets $fid line] != -1} {dict incr lines [string trim $line]}
close $fid
dict for {line count} $lines {if {$count > 1} {puts "duplicated: $line"}}
duplicated: 2 0
duplicated: 3 5