User Control Panel
Advertisements
HELP US, HELP YOU!
Author
Message
Calum Not Yet a God Joined: 21 Feb 2004Posts: 373 Location: england
Posted: Tue Mar 09, 2004 10:41 pm Post subject:
its kinda crap it records who gave the points to which user and how many so it comes out like calum@iamwasted.com awarded user: billy@bill.com 5 points calum@iamwasted.com awarded user: billy@bill.com 10 points it doesnt add them up im a noob to perl so its best i could do if any one wants it just post
Back to top
Cer Upgraded Agent Joined: 03 Feb 2004Posts: 3776 Location: Michigan votes : 4
Posted: Tue Mar 09, 2004 11:51 pm Post subject:
Here's my shot at it. Code: if ($msg =~ /\^points/i) {<br /> # Open points file<br /> open (FILE, "points.txt");<br /> my @data = <FILE>;<br /> close (FILE);<br /> chomp @data;<br /><br /> # Go through file<br /> %temp;<br /> foreach $line (@data) {<br /> my ($sender,$void,$void,$to,$points,$void) = split(/ /, $line, 6);<br /><br /> if (exists $temp->{$sender}->{$to}) {<br /> $temp->{$sender}->{$to} = $temp{$sender}->{$to} + $points;<br /> }<br /> else {<br /> $temp->{$sender}->{$to} = $points;<br /> }<br /> }<br /> # Send reply.<br /> my $reply;<br /> foreach $key (keys %{$temp}) {<br /> foreach $item (keys %{$temp}->{$key}}) {<br /> $reply .= "$key awarded $item: " . $temp->{$key}->{$item} . "points\n";<br /> }<br /> }<br />}
That probably confused you a ton... but that's the easiest way I can think to do it, using hashes. _________________ Current Site (2008) http://www.cuvou.com/
Back to top
jeanhub Almost An Agent Joined: 14 Feb 2004Posts: 1138
Posted: Wed Mar 10, 2004 12:13 am Post subject:
I am trying to make a "award" command its hard lol
Back to top