yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Perl Lesson 1


3m read
·Nov 3, 2024

Processing might take a few minutes. Refresh later.

M 101 here. Today, this is going to be a Pearl lesson. Um, what Pearl is, is a programming language. See, a few of you, who happen to be older than most of our viewers, want something more complex and advanced than just these simple terminal commands. So, I'm going to be showing you how to make a program with terminal and how to make it do stuff.

So, this is Pearl lesson one. There are going to be a few of these, but for now, I'm going to be demonstrating this to you on my desktop like normal. Um, so as you can see, I'm gonna have to go into VI or Nano to make a document. I'm just going to do VI, but you can use Nano, so I'm going to do VI, and I'm going to call my program wi.

Now, um, the first line of your Pearl script you're going to want to make is hashbang slash user slash bin slash Pearl. Put that up on the screen, and yes, user has no e in it. Now a hash is shift three, and the bang, also known as an exclamation point, is shift one.

Now, uh, we go on to the next line, and we want to type our Pearl script. So now we can type there are a few commands for the script. I'll just start you off with something simple that you're going to be bored with, but it's useful and worth it. Print, and this displays text on the screen.

So with print, you do print space quote, and now we want to type something to print out, like "Hello, my name is Dave," and then we're going to do a close quote. At the end of every line, except for the first line, which is hashbang user bin Pearl, we want to put a semicolon.

Um, so now hit enter, and now I printed out "Hello, my name is Dave." And so I'm just gonna save this right now. So here's my text document on my desktop called wi. Now we want to type a command to basically activate it: chmod space +X space and then the name of your document, by in case it's WI.

So now my document looks like this on Tiger. It should look like a terminal. On Tiger, you're not just going to be able to double-click it, but that's okay. So now you want to, um, I'm just going to edit wi again, and now say I have a print that says "Hello, my name is Dave." It's going to print out "Hello, my name is Dave," because that's what I wrote.

So on Tiger, you can just drag wi into your terminal and then click the terminal and hit enter, and then it says "Hello, my name is Dave" right there. Unfortunately, it didn't print a new line, so it goes straight to my prompt. So I need to edit that.

So here's how you do a new line; in the quotations, you do backslash n. Backslash n is a new line, so "Hello, my name is Dave!" backslash n. So I'm printing a new line after "Hello, my name is Dave." Now I'll just drag wi in, click enter, now I printed out "Hello, my name is Dave" and then went to the next line.

Now wi happens to be an executable, and it's in my current path. wi is right there, so I can just type ./wi and say "Hello, my name is Dave." And on Leopard, I can just open it up and it'll say "Hello, my name is Dave."

So yeah, so now I'm going to edit wi again, and on the next line, I'm going to say print "What is your name?" backslash n quote semicolon. So now it's going to ask me what my name is. Now, unfortunately, I can’t type anything back. As you can see, look at this: "What is your name?" Now I'm typing on my prompt again. I'm not going to type my name as a command because it’ll say command not found.

So how am I going to take my name as input? I want to type dollar sign. Then let's just call it shizzel for now space equals space less than STDIN greater than semicolon. So now, here’s what dollar sign shizzel is. Whenever you have a dollar sign and then a word, it declares a variable called whatever the word after the dollar sign is.

In my case, it's shizzel. I say shizzel, which is now a variable equals, you know, less than STDIN greater than. What does STDIN stand for? Standard input. So that would be the way of input, which in this case is the terminal. So shizzel is standard input.

So now I’m just going to run wi again, and it says "What is your name?" Now it's giving me a chance to type, and I type my name. So now, of course, my name has been assigned to whatever they type in the standard input. Now let me just explain a variable.

More Articles

View All
Quantity theory of money | AP Macroeconomics | Khan Academy
In this video, we’re going to talk about the quantity theory of money, which is based on what is known as the equation of exchange. It tries to relate the money supply ( M ) (so this is some measure of the money supply) with the real GDP ( Y ) (so that is…
Ask me anything with Sal Khan: April 20 | Homeroom with Sal
Hi everyone. Welcome to the daily homeroom livestream! This is just a way for all of us to stay in touch during this time of school closures. As we have in homeroom in the real world, the physical world, which we all now really miss, it’s a time for us to…
How to sell a corporate jet!
Yes, sir. I have a customer from overseas who would like to purchase an airplane. Do you know what kind of airplane he’s looking for? From what I understand, they’re looking at a Lear Jet 60XR. Does that mean anything to you? Yeah, I know it does, but th…
Derivatives of inverse functions | Advanced derivatives | AP Calculus AB | Khan Academy
So let’s say I have two functions that are the inverse of each other. So I have f of x, and then I also have g of x, which is equal to the inverse of f of x, and f of x would be the inverse of g of x as well. If the notion of an inverse function is comple…
TIL: These Birds Trick Others Into Raising Their Gigantic Kids | Today I Learned
[Music] Turns out there’s lots of different birds that don’t build nests at all. They only lay their eggs in other birds’ nests. This behavior is called brood parasitism, and a trick is you have to make an egg that looks like all the other eggs. Otherwise…
Backspin Basketball Flies Off Dam
Recently, some friends of mine went to the Gordon Dam in Tasmania, which is 126.5 meters (or 415 feet) high. Then they dropped a basketball over the edge. You can see that the basketball gets pushed around a bit by the breeze, but it lands basically right…