So for no other reason than that I bore easily with repetition, I decided to start the camel anyway, and I'm so glad I did. Just my reading of much of the first chapter last night in bed was both entertaining and very illuminating. All of the books I've used so far kind of dive right in and get into the mechanics of Perl (here's what we mean by the term "scalar literal," here's how you use this or that kind of value/variable, how to control the flow of your program with loops and conditionals, etc.) without talking much about the rationale. The first chapter of the camel (which is co-authored by Perl creator Larry Wall) gets a little into the nuts and bolts of Perl, but is mainly a conceptual overview, and focuses on the logic of why Perl is the way it is.
I'm a fairly "foundational" thinker, which is to say that if you provide me with a solid conceptual framework of any given system, along with some rationale as to why it's built that way, I will understand how the system works. The "how" and the "why" are very much connected for me as a learner, and when I have had the opportunity to train people on things like library information systems, I nearly always teach from a "systems" view. This may be confusing the hell out of my poor trainees, but I've never had someone tell me so. Some people - maybe most, given the approach of most teaching guides - just want (need) to know the "how" and don't really care about the "why" - that's not me.
So I've learned from my other books how to create a scalar variable (a "scalar" value is a single thing, like a number or a text string) by saying something like
$sys_admin = "chris";
You create an array (list) similarly, except, rather than the $ sign you use @:
@pines_staff = ("Ellen", "Bob", "Frank", "Louise");
All of the books I've used (including the llama so far) do this similarly and then turn around and say "Wow! You just wrote your first Perl program!" which leaves me kind of blinking, going "I did what now?"
In a few short paragraphs within the first few pages of the camel, though, I learned:
All of the books I've used (including the llama so far) do this similarly and then turn around and say "Wow! You just wrote your first Perl program!" which leaves me kind of blinking, going "I did what now?"
In a few short paragraphs within the first few pages of the camel, though, I learned:
- That a scalar value is a single instance of a "noun" (e.g. "this particular baseball in my hand").
- That a scalar variable is a way to contain the "idea" of a baseball without necessarily referring to a particular baseball. It could be the one in my hand, but it could also be the one that won the Braves' game on a grand slam.
- That the symbols for Perl variables look like the first letters of what kind of variable it is ($ is for scalar, @ for array).
- That the difference between an array (a simple list) and a hash (a list of paired values, usually arranged in a table) is that in an array you can look up the value by number (order in the list) and in a hash you can look up the value by name (the first value of each pair).
No comments:
Post a Comment