note
Ri-Del
Instructions for Newbies: <BR>
Part A<BR>
What do you think the output of the code below is? <BR>
<BR>
I figured that the result would be "In the beginning there <BR>
was nothing, in the end there will be nothing."<BR>
<BR>
Part B<BR>
Give an accurate explanation for your answer. <BR>
<p>
The reason I assumed this, was because I thought that
<CODE>@_ = qw(alpha, omega);</CODE> assigned the values "alpha" and "omega" to an array called "_". While, <CODE>$_ = qw(nothing, nothing);</CODE> ends up assigning the value "nothing" to a scalar variable called "_". Which I think is related somehow to the manner in which we call the array "_". Hmm, perhaps we are actually altering something with the array by assigning a value to the $_ variable? I've just started learning perl and I seem to remember reading something about that.
</p>
<p>
Part C
What happens when you replace "subroutine ();" in line
7 with "&subroutine;"? Why?
</P>
<P>
Well, I had to go look it up, because quite frankly I had no clue whatsoever. However, it appears that by placing an '&' in front of the <CODE>"subroutine ();"</CODE> call is really no different than not putting it in front because of the fact that the '&' prefix is considered to be optional. According to the second edition of the camel book, on page 114, it seems that when one names a subroutine, or if one is attempting to get a reference to a subroutine, or if one wishes to "do an indirect subroutine call with a subroutine name or reference using the &$subref() or &{$subref}() constructs..." then the '&' is not optional.
</P><P>
Another Question:
When I attempted to add "-w" and then correct the "Use of uninitialized value in concatenation (.) at brain2.pl line 10." I think I realized that in fact we are using something that really isn't a variable or an array. So um.. I thought maybe @_ and $_ are actualling something else,
so that is when I decided to go to the index of my trusty Camel II book. I think I realize where I went wrong and it is related to the error I recieved when I added "-w". Apparently $_ and @_ are actually global variables. But my question is, what exactly are they? Are they the arguments that are passed in when I run the script?
</P>
72671
72671