This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Stop it starting a new line for every space in a line

Old posts that have not been replied to for several years.
Locked
u
uTc

Post by uTc »

What can i do to stop it from starting a
new line for every space in a line say i was pulling some info from a page and it looked like this:

<title>Mining Unstructured Data</title>
<url>http://slashdot.org/article.pl?sid=02/0 ... 19233</url>
<time>2002-03-15 23:18:33</time>
<author>michael</author>

it would return it like:

<title>Mining
(BoT) Unstructured
(BoT) Data</title>
(BoT) <url>http://slashdot.org/article.pl?sid=02/0 ... 19233</url>
(BoT) <time>2002-03-15
(BoT) 23:18:33</time>
(BoT) <author>michael</author>

which is starting the lines with spaces on a new line each time.

so with this script its not returning the title cause its split up and cant find <title> and </title> on one line for foreach...

bind pub - !slash slash
proc slash {nick host hand chan arg} {
set url "/slashdot.xml"
if {[catch {set sock [socket -async slashdot.org 80]} sockerr]} {
putserv "PRIVMSG $chan :$sockerr"
close $sock
return 0
}
puts $sock "GET $url"
flush $sock
set slash [gets $sock]
close $sock
foreach line $slash {
puts $line
set i [string first "<title>" $line]
if {$i != -1} {
set j [string last "</title>" $line]
putserv "PRIVMSG $chan :02[string range $line [expr $i + 7] [expr $j - 1]]02"
} else {
set i [string first "<url>" $line]
if {$i != -1} {
set j [string last "</url>" $line]
putserv "PRIVMSG $chan :([string range $line [expr $i + 5] [expr $j - 1]])"
}
}
}


}
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

gets only returns one line, and then your foreach loop is reading each word in that line.
Locked