Re: Having problem with SPLIT



Earl Grieda wrote:
"Ralf Fassel" <ralfixx@xxxxxx> wrote in message
news:yga1x6j99zj.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxx

* "Earl Grieda" <egriedaNOT@xxxxxxxxxxxxxxxxxxx>
| if {$::DEBUG} {puts "FIRST0: $orgLine"}

Please show how 'orgLine' is set.
Is it
 set orgLine "\tHeader with a tab"


orgline is set by reading a file (the email file).
  set orgLine [gets $inputFileID]
and the line in the email file is
  \tHeader with a tab     ;# \t is 2 chars

I then do
  set line [split [regsub -all { +} $orgLine " "]]
to insure there is only one space between each word and make it a list so I
can use list operations on it.  The idea being that the first item in the
list is a flag and, depending on the flag, some action is done with the rest
of the line.

Ok, so you're reading a string and you're trying to treat it as a list of space-separated words. Only, it's not really a list of space separated words, it's really just a string with no guarantee of the format (other than the first "word" is really a flag).


That seems like a recipe for disaster.

Since you're only interested in the first word at this point, how about just pulling out the flag and leaving the rest of the data alone?

    # put in whatever pattern fits your actual data
    regexp {^([a-zA-Z0-9_]+)} $orgLine -- flag

Is there a specific reason you're converting a string to a list, other than to make it easy to pick out the first word? It looks like the crux of your problem is that program A is changing the nature of the data before passing it to B. Thus, B gets a string representation of a list representation of the original string, which is not the same as the original string.



.