The pertinent portion of my script:
foreach swap $subs {
set swapL [split $swap “.”]
set swapsegL [split [lsearch -inline -all -regexp $segments [lindex $swapL 0]] $sep]
set swapfield [split [lindex $swapsegL [lindex $swapL 1]] $sub]
set newfield [join [lreplace $swapfield [lindex $swapL 2] [lindex $swapL 2]] $sub]
set newseg [join [lreplace $swapsegL [lindex $swapL 1] [lindex $swapL 1] $newfield] $sep]
set segments [lreplace $segments [lsearch $segments [lindex $swapL 0]*] [lsearch $segments [lindex $swapL 0]*] $newseg]
}
When I tested this the first time, my PID segment returned as a list, even though I had joined it by the separator. I was able to fix it by modifying the above line to read:
set newseg [join [join [lreplace $swapsegL [lindex $swapL 1] [lindex $swapL 1] $newfield] $sep] “”]
It’s working now, but I was hoping to get clarification as to why I needed a second join to turn the PID segment into a string before placing it back into the segments var. I’ve run into this before, and would like to understand why this happens.
Thanks in advance!