tags:

views:

31

answers:

2

Hi,

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.

+5  A: 

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.

musiKk
@muskik : thanks a lot for that :) actually i couldn't find this in the book , could you please tell me from where i should learn the basic stuff.Also, can the self and message be any name ?
pranay
@pranay: 2. Yes you can. 1. _Programming Perl_ from Larry Wall himself is always recommended. I learned with _Beginning Perl_ which is freely available on the net (http://www.perl.org/books/beginning-perl/). It is fine for the basics but doesn't cover to many advanced topics (which might be good or bad depending on the reader). Which enough curiosity you learn the advanced stuff as well though.
musiKk
@n0rd: Thanks, since it is also updated in the question I edited my answer accordingly. I hope you don't mind (because now your comment is out of sync, +1'ed you though).
musiKk
@musikk:thanks a lot
pranay
+1  A: 

Read perldoc perlreftut for Perl references tutorial.

n0rd
thanks a lot for that .
pranay