Sagacity has asked for the wisdom of the Perl Monks concerning the following question:
For the benefit of those who didn't get to see the original post of this question
I was confused about the movement of the actual data and how it is accessed in sub-routines within a package.
I was also confused about the structure/style I could use to write code that I didn't have to continually use my within those sub-routines, since the constructor created those variables to start with. This was answered by kyle with a simple change of scope, or the use of $self->{variable}.
The second part of the node is still up for grabs as far as a good visual for the arrangement of data flowing to the package.
The reason for this question is: When I use sub-routines in a package. If I wanted to get the value that was passed, I had to use the my $var = shift;, otherwise, the value passed didn't get assigned. So to clarify -- the question really is; What are we shifting?
I believe it is the array @_ .
Any pointers to docs, or answers will be greatly appreciated.
If there is a way that one of you gurus could help draw a simplistic picture of a few things in OOP Perl, it would be wonderful.
Since Kyle showed me the visual for encapsulation, Thanks Kyle!
I am still pondering the visual on the look of the data as if it were maybe an array like so:
information_heading_to_server{Classname, first_piece_of_data, second_piece, third_piece}.
This may seem trivial, but it helps me to understand the
my $self = shift; followed by my $whatever = shift;
I get the self shift call to handle the first argument being the classname, but what about the others? Is the classname also the first element there too?
|
|---|