From the beginning!
If you guys are anything like me, you like to learn a lot of things. One of the things that has been on my list of things to learn has been perl. It’s useful in many things, and a pretty extraordinary.
Dispite the fact that I have a basic understanding perl, I’ve decided to start all the way back at the beginning and bring you all on my journey. A journey that will take time, and patience.
First things first. If you don’t have Moose and REPL installed, get it. I demand it. They’re the most useful things in the world.
Here, I’ll even tell you how to do it with ubuntu.
sudo apt-get install libdevel-repl-perl libmoose-perl
Or
cpan Moose
Devel::REPL
So, the reason for all of this? We’re starting at the very beginning, Boolean Algebra.
Boolean Algebra is the logical calculas that programming is based on. (From my understanding. I’m sure everyone has a different discription. Feel free to share them, in the comments.)
Actually, if you want to learn more in-depth about the boolean logic processes, wikipedia has a very wonderful article. you can just look it up.
To start, we’ll need to learn a few operators.
We’ll start with the easiest || (or) and && (and)
So, pop open a terminal and install moose and repl (If you haven’t already.) While you’re waiting, here is some stuff that i tried and a few of the results that I’ve discovered. (This assumes you know something about input. If you don’t, just follow along, It’ll make more sense as you go one.)
$ if( 1 || 0 ) { return “Truths” } else { return “Falsehoods!” }
Truths
$ if( 0 || 0 ) { return “Truths” } else { return “Falsehoods!” }
Falsehoods!
So, now that you’ve got that installed, and I’ve got some good examples up there. Well start with the first.
if( 1 || 0 )
this says, if one or zero. if true or false. Both could be correct. I’m not exactly sure, yet.
Mostly, you’ll want to play with it a lot.
Tell y’what. I’ll meet you back here in a few days, and post another lesson!
Things I learned this time; operators || (or), && (and), ! (not), != (not equal to), == (is equal to), < (less than), <= (Less than, or equal to), >= (greater than or equal to), > (greater than), + (plus), - (minus), * (multiplied), / (divided), ** (exponental)
$ if( 1 + 0 >= 0 ) { return “Truths” } else { return “Falsehoods!” }
Truths
Simple steps. Play around with all the different operators. You’ll find yourself wanting to more and more. I know I did!
Hopefully I’ve not been too confusing.
-L