proc some:proc {nick host handle channel text} {
set url [lindex [split $text] 0]
set result [lindex $text 1]
set token [::http::geturl $url]
set content [::http::data $token]
::http::cleanup $token
foreach line [split $content \n] {
set output [lindex $line 0]
sendmsg $channel "$result $output"
}
}
If the lastline is an emptyline (its not always like this) i get $result without $output, as theres nothing to output. How can i drop that last/empty line ?
Thanks!
I'd want to test this myself to verify, but that method should be fine, as its checking to see if each line has something. Here's a few more ways I think would work, starting at that foreach loop:
A few comments on the posted codes:
Regular expressions are flexible, but far slower than other kinds of matching.
Using llength on a string is a bad idea. In worst case, llength might throw an error due to "improper list", which will immediately terminate the proc.
Same goes with using lindex on strings...
Both $text and $line are strings, not lists. Use the split-command to get a valid list, if you intend to use list operations.