简体   繁体   中英

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 @_ is 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.

阅读perldoc perlreftut,以获取Perl参考教程。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM