开发者

Difficulty in building an irc bot via Bot::BasicBot

I am completely new to Perl. I am trying to build a basic IRC bot.

In the module Bot::BasicBot, what does the line my ($self, $message) = @_; in the "said" function mean? I do know that my is for private, and @_ i开发者_StackOverflow社区s the array for receiving parameters in the function, but how is a hash reference passed here?

Also, how do I access the parameters "who", "address", "body"? Thanks.


Well, these are Perl basics. You should start learning it first before you write bigger programs. If you know programming at all, this shouldn't take that long. Although I answer your question I really urge you to do it.

@_ is indeed for arguments. $self is the object the said() method is called on and $message is the parameter which indeed is a hash ref according to the documentation. You get the values out of a hash ref via $message->{who} etc.


Read perldoc perlreftut for Perl references tutorial.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜