We started learning Perl yesterday in Unix class. Nothing fancy, just the basics. I'm semi-confused on it all.
For our first program, we counted the number of lines in a file called students, which was passed to the command line. It went like this:
$filein = $ARGV;
Or along those lines. Then, we had an open statement. Just fine. Here's where I'm getting confused at.
?? Maybe whiles here don't work the same as they do in basic or C++, but it looks to me like that statement doesn't have anything comparing that while to, so logically, the loop should continue. And, what's up with the _$?? Is that supposed to be some kind of 'get input from file' statement?
Next program wasn't too bad. A lot of the same stuff. We predefined the file's name this time.
The program after that was where things started to get hairy.
The program started with
I understand that.
went down, and
Ok, that part doesn't bother me. That was about the sum of the program, but nowhere in there did I see an open statement, nor did I see a way to pull the variable off of the command line like I did with the first program. This is what confuses me. How, if I did not write the code to do so does the language know to pull the variable off of the command line, and know that the variable in question is a file and not something else, and how does it read and interact with the file without me telling it to? It's spooky. I hope this doesn't sound like mindless rambling to the vets of the language, but you can see my confusion coming from a language like C++ or similiar. You've got to tell it to do something, it doesn't do it unless it has the code to do it. If it does it automatically, I'll accept it with blind faith, much like I accept the fact any number raised to the 0th power is 1. I don't understand the logic, or the reason why, but since it's written in stone, I accept it. Even my teacher is confused. It's not that he doesn't understand it himself, it's just that no one has ever gotten this far in the Unix book, they all got hung up on the fact that "It's not windows.". So, we've gotten the farthest, and thus, the first time he's seen the problem. Some clarity, please?
I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.