Hi all, I'm having a look in to object oriented perl. Can anyone tell me what the difference between @_ and shift is? As far as I know there is no difference except "shift" removes the parameter from the @_ array so if you were to "shift" all parameters passed to a function nothing would be containted in @_ is this correct?

I'm asking because I'm a little confused about using it. Why can't I do this:

#######################################
sub nickname {
       my $self = shift;
       return $self->{NICK};
}
#######################################

But I can do this:

#######################################
sub nickname {
       my $self = shift;
        if (@_) { $self->{NICK} = shift
        }
       return $self->{NICK};
   }
#######################################

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to