The problem is all down to the fact, you are not working on a list, and you are using exact matching.
While there is nothing legaly wrong (in terms of differance between string and list) with the value of $list, the values arr as follows
Code: Select all
foreach item $list {
puts stdout "Item: $item"
}
produced
Item: Monday,
Item: 27
Item: January
Item: 2003
Note the coma?
"lsearch" does an exact search (By the way, -exect and glob are the same, only wildcards are not translated, which saves CPU. However, passing "Monday" in both -exact and -glob modes works the same), for monday, and doesn't find it. So it returns -1 to the valud of $index.
Using -1 as the index in replace, causes the item to be prepended, and doesn't replace a thing.
If you searched for "Monday,", all would work fine.