Joined: 10 Jun 2004 Posts: 560 Location: North West, England
Posted: Fri Dec 31, 2004 7:16 pm Post subject:
in elsif
Code:
#Made By Purcelly <br />#For Innington<br /><br />if($msg =~ /^!work/)<br />{<br />&send($self,"Here is one way to get out of going to work:");<br />open (FILE, "./work.txt");<br />@bat = <FILE>;<br />close (FILE);<br /> $result = $quotes[int(rand(scalar(@quotes)))];<br /> $self->sendmsg("$result", Font => "Arial",Color => '017151',Effect => "B");}<br />}
Ok, so basically you've shown everyone had to get a random line from a text file. And you've shown that to us in FOUR different posts. You could easily make one function that takes a text file and returns a random string from it. Then you could have posted text files to use with it. Also, no matter how many thousand times we've told people to use my in their code, you stil don't. That's just going to lead to bugs in the future.
Also, why not make the functionality interesting and allow searching: !work fish, which would find a random work excuse related to 'fish'.
EDIT: Make that FIVE copies of basically the same code. You need to learn how to factor out common functionality to reduce code size AND make it more powerful.