Thats the result and i want it gone! It affects it when i send it back out but i don't understand whats causing it,I can't see no differnce in the text file (One word perl line, no leading spaces,lines)
Heres the code
Code:
sub start_top10{<br /> <br /> <br /> #Lets pick if its a bonus round or not, odds are 10::1<br /> my $roundno = int rand 10; <br /> my $round = "normal";<br /> if($roundno == 1){$round = "bonus";}<br /> <br /> #lets pick a random topic in our round.<br /> my @array = glob("./Stuff/top10/$round/*") if(defined $round);<br /> my $file = $array[int(rand(scalar @array))];<br /> <br /> #get the answers!<br /> open (ANS, "$file") if (defined $file) or warn("Could not open");<br /> my @content = <ANS>;<br /> <br /> my ($category) = $file =~ m/$round\/(.*?)\.txt/isg;<br /> $bot->{store}->{general}->{chatrooms}->{top10}->{category} = $category;<br /> delete $bot->{store}->{general}->{chatrooms}->{top10}->{answers};<br /> delete $bot->{store}->{general}->{chatrooms}->{top10}->{found};<br /> foreach $answer (@content){<br /> $letters = substr($answer,0,3);<br /> $letters = lc ($letters);<br /> $bot->{store}->{general}->{chatrooms}->{top10}->{answers}->{$letters} = $answer;<br /> }<br /> &chatAnnounce("New Top10 Round starting!\nThe topic is set to $category and it is a $round round...\n\nStart!","top10","660000") if (defined $file && defined $round);<br /> close ANS;<br /> &save;<br />}
And Heres an example of the text file that was used with that one ^^
i even tried removing all the white space before storing it with a tutorial on here but nothing seems to do the trick..
Hint : I dont think its the text files its self but the code because it happens once for every text file. But not in the same place so i cant see no pattern.
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Tue Mar 08, 2005 9:39 pm Post subject:
You want to chomp your file. Also beware that if you are making the text file on windows, and transfering it to linux (or vice versa) then you will have file ending trouble.
Code:
<br />open (ANS, "$file") if (defined $file) or warn("Could not open");<br />my @content = <ANS>;<br />chomp(@content);<br />
That will remove the line ending of each line, probably fixing your issue. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com
Umm, the chomp will remove any "new lines" (\n) from a string, which is exactly what you want. _________________ ~ Josh
[ Need bot hosting on a dedicated server? PM me. ]