http://wholok.com/data/code/Trivia.pm
http://wholok.com/data/code/triviabot.pl

I am quite a novice with regard to perl and I am trying to get some code working.

The two links above contain code for a trivia bot to run on IRC. The questions and answers for the bot are supposed
to be stored in a database, but there is no explanation of what the structure of the database should be.

So far I have created a database named "trivia" and two tables, one called "trivia" with two fields "question" & "answer",
and the other table is called "scores" with fields named "nick" and "score".

Using the above structure, the bot can successfully send questions to a channel and accept the correct answer
and increment the score of the nick who answered correctly.

Where I am having difficulty is with the "!score" command the bot uses to display your score.

When the "!score" command is used the bot crashes with the following message

"DBI selectall_hashref: invalid number of arguments: got handle + 1, expected handle + between 2 and -1
Usage: $h->selectall_hashref($statement, $keyfield [, \%attr , @bind_params ]) at Trivia.pm line 165."

Trivia.pm line 165 = return $obj->{dbh}->selectall_hashref("SELECT * FROM scores") ;
from the get_score routine.
sub get_score { my $obj = shift; return $obj->{dbh}->selectall_hashref("SELECT * FROM scores") ; }

I don't know what line 165 means.
I am guessing it is trying to read the scores from the table but finding the format of the fields to be incorrect.

Can I get some help regarding my problem?
cheers

In reply to Reverse engineering some code :( by ceilingcat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.