Yes, shift operates on @_ by default, which is also the array that contains
all arguments passed to the subroutine.  You are probably right that "Sheep"
is the only item in the list, due to the shift/pop behavior you mentioned.

-----Original Message-----
From: montana [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 15, 2002 2:41 PM
To: [EMAIL PROTECTED]
Subject: Newbie Question.


I've been looking through the manual perlboot. This is a beginners tutorial
on Perl OOP.


One of the practice programs in this manual had the following line:
my $class = shift;

This was located in the subroutine:
sub Sheep::speak {...}

>From what I've gathered so far, "my" makes the variable "$class" local to
the subroutine only? Is this correct? "shift" takes the leftmost value out
of a list and places it in the variable $class? Is this correct? If I got
all of this correct, where is the array that shift is working on and why use
shift instead of pop? Also what are the contents of this array and how can I
see them? I know that that line of code places the value "Sheep" into
"$class", I was just wondering how this works in plain English? I'm
guessing, and please correct me if I'm wrong here, the array is "@_"? And
this array contains the current class name "Sheep" as it's only item? And
this is why "shift" and "pop" produce the same results?

Thanks in advance.
SA

"I can do everything on my Mac that I used to do on my PC, plus alot more
...."
--Me

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to